Page Index Toggle Pages: [1] 2 
Topic Tools
Hot Topic (More than 10 Replies) Adding Global Vars - How do I? (Read 4,243 times)
Lopa
Junior Member
**
Offline



Posts: 95
Location: Australia
Adding Global Vars - How do I?
Sep 26th, 2010 at 5:54am
Post Tools
I'm back again! with an earnest request?

Is there a way to globalise variables so that one doesn't have to crawl through every template.pl and add variables to the different sections that affect all the different templates?

I've been playing with Display.pl and Display Template with this:

Code (Perl)
Select All
$template_vistatop = qq~<table width="100%" border="0" cellpadding="0" cellspacing="0" align="center"><tr><td align="right" width="11"><img src="$imagesdir/vista/tbl_top_l.png" width="11" alt="" /></td><td class="tbl_top_c" width="100%"></td><td width="11" align="left"><img src="$imagesdir/vista/tbl_top_r.png" width="11" alt="" /></td></tr><tr><td class="tbl_l_s" width="11"></td><td>~;
$display_template =~ s/({|<)yabb vistatop(}|>)/$template_vistatop/g;
$display_template =~ s/({|<)yabb vistatop(}|>)/$template_vistatop/g;

$template_vistabottom = qq~</td><td class="tbl_r_s" width="11"></td></tr><tr><td width="11"><img src="$imagesdir/vista/tbl_f_l.png" width="11" height="10" alt="" /></td><td class="tbl_f_c"></td><td width="11"><img src="$imagesdir/vista/tbl_f_r.png" width="11" height="10" alt="" /></td></tr></table>~;
$display_template =~ s/({|<)yabb vistabottom(}|>)/$template_vistabottom/g;
$display_template =~ s/({|<)yabb vistabottom(}|>)/$template_vistabottom/g; 



As I'd like to modify all the templates by simply using {yabb vistatop} etc as I've found that one has to add the var to different sections of single .pl files for it to work. And that's a LOT of work!


If yes it can be done - I'd also like to know how to include and use a "Custom_Vars.pl" for adding the mark up to the templates as it makes it so much easier to create new themes.

Danke!
Grazzie!
Thanks!
Obsobosoloy!
Cheers!

« Last Edit: Sep 26th, 2010 at 9:54am by Lopa »  

I make mistakes - That's how I learn.
Back to top
WWW  
IP Logged
 
Derek Barnstorm
Support Team
YaBB Next Team
Development Team
Beta Testers
****
Offline



Posts: 1,269
Location: United Kingdom

None
Re: Adding Global Vars - How do I?
Reply #1 - Sep 26th, 2010 at 4:16pm
Post Tools
Hi,

I'm certainly no expert here and I've only given this a quick test, but this should do what you want...

I've attached Custom_Vars.pl to this post (Note, you'll have to change the .txt extension back to .pl) - Upload it to the Sources directory.

You can basically make a global tag like this:

Code (Perl)
Select All
$yytestvar = qq~This is a test~; 


Which will give you this tag: {yabb testvar}.

Anyway, I've added the tags that you wanted as a quick example - it is very simple so you should see how it works.

Then, in YaBB.pl find this line:

Code (Perl)
Select All
	require "$sourcedir/Load.pl"; 


And add after:

Code (Perl)
Select All
	require "$sourcedir/Custom_Vars.pl"; 


And you should be good to go...
« Last Edit: Sep 26th, 2010 at 4:17pm by Derek Barnstorm »  

Custom_Vars.txt ( 1 KB | 102 Downloads )
Back to top
 
IP Logged
 
Lopa
Junior Member
**
Offline



Posts: 95
Location: Australia
Re: Adding Global Vars - How do I?
Reply #2 - Sep 27th, 2010 at 11:51am
Post Tools
Thanks Derek,

You're spot on and possibly saved me about 24 hrs of reading this stuff trying to find out what goes where.  Wink

Got another problem you may want to try to help with - and here it is ->  Undecided

Here's how I ended up doing the tables as I found out that  $imagedir wasn't going to work in the original:

Code
Select All
$imagepath = "$yyhtml_root/Templates/Forum";
$imgextg = "gif\" alt=\"\" border=\"0\"";
$imgextp = "png\" alt=\"\" border=\"0\"";

$yytbl_top_l = qq~<img src="$imagepath/default/vista/tbl_top_l.$imgextp" />~;
$yytbl_top_r = qq~<img src="$imagepath/default/vista/tbl_top_r.$imgextp" />~;
$yytbl_f_l = qq~<img src="$imagepath/default/vista/tbl_f_l.$imgextp" />~;
$yytbl_f_r = qq~<img src="$imagepath/default/vista/tbl_f_r.$imgextp" />~;

$yyvistatop = qq~<table width="100%" border="0" cellpadding="0" cellspacing="0" align="center"><tr><td align="right" width="11">{yabb tbl_top_l}</td><td class="tbl_top_c" width="100%"></td><td width="11" align="left">{yabb tbl_top_r}</td></tr><tr><td class="tbl_l_s" width="11"></td><td>~;

$yyvistabottom = qq~</td><td class="tbl_r_s" width="11"></td></tr><tr><td width="11">{yabb tbl_f_l}</td><td class="tbl_f_c"></td><td width="11">{yabb tbl_f_r}</td></tr></table>~;
1;
 



And that works sweet - as you can see here ->
http://members.iinet.net.au/~cranky65/cgi-bin/forum/YaBB.pl

But! I'm running two themes and while I want to use the same VARS, I also need to separate them as in "default" and "blue".

Ok, so I tried splitting the request with:

Code
Select All
if (-e "$yyhtml_root/Templates/Forum/default_vista.css")
{
Do this etc!
}

And

if (-e "$yyhtml_root/Templates/Forum/blue_vista.css")
{
Do this etc!
} 



But I don't think "filecheck" works outside of the cgi-bin?

So I went another way - - - darn it! I'll go table-less and let the .css look after it with:

Code
Select All
$yyvistatop = qq~<div class="t"><div class="b"><div class="l"><div class="r"><div class="bl"><div class="br"><div class="tl"><div class="tr">~;

$yyvistabottom = qq~</div></div></div></div></div></div></div></div>~;

and the CSS:

.t {background: url(./default/vista/vista_top_c.png) 0 0 repeat-x;}
.b {background: url(./default/vista/vista_bot_c.png) 0 100% repeat-x;}
.l {background: url(./default/vista/vista_l_s.png) 0 0 repeat-y;}
.r {background: url(./default/vista/vista_r_s.png) 100% 0 repeat-y;}
.bl {background: url(./default/vista/vista_bot_l.png) 0 100% no-repeat;}
.br {background: url(./default/vista/vista_bot_r.png) 100% 100% no-repeat;}
.tl {background: url(./default/vista/vista_top_l.png) 0 0 no-repeat;}
.tr {background: url(./default/vista/vista_top_r.png) 100% 0 no-repeat; padding:11px;}
 



YaBB DIDN'T LIKE IT!  because it conflicts with some other div placements and tables - darn! Angry

So I need to create a valid argument that either checks for a file outside of cgi-bin or a checkable $var statement of some sort that knows what theme file is in current use?

It's been a long day - - - And don't be like me! - - Make sure you have some breakfast before you start answering this!  Grin Grin Grin
« Last Edit: Sep 27th, 2010 at 12:13pm by Lopa »  

I make mistakes - That's how I learn.
Back to top
WWW  
IP Logged
 
Derek Barnstorm
Support Team
YaBB Next Team
Development Team
Beta Testers
****
Offline



Posts: 1,269
Location: United Kingdom

None
Re: Adding Global Vars - How do I?
Reply #3 - Sep 27th, 2010 at 1:35pm
Post Tools
Told you I wasn't an expert. Cheesy

Sorry, I didn't check the images, I assumed it would pick them up.

Anyhow, using the {yabb images} tag which is already there seems to do the trick. So instead of this:

Code (Perl)
Select All
$imagesdir/vista/tbl_top_r.png 


Try this:

Code (Perl)
Select All
{yabb images}/tbl_top_r.png 


Again though, I have only tested quickly...
  
Back to top
 
IP Logged
 
Lopa
Junior Member
**
Offline



Posts: 95
Location: Australia
Re: Adding Global Vars - How do I?
Reply #4 - Sep 27th, 2010 at 11:59pm
Post Tools
Thanks Derek,

Derek Barnstorm wrote on Sep 27th, 2010 at 1:35pm:
Told you I wasn't an expert.


That's two of us!  Wink

"yabb images" VAR appears to always take me to the "default" folder - which is not much use really for what I'm trying to do.  Cry

But if CJ wants to get on board and give me an argument that "Knows" what theme is being used - Then I'm nearly there.
Smiley
  

I make mistakes - That's how I learn.
Back to top
WWW  
IP Logged
 
Derek Barnstorm
Support Team
YaBB Next Team
Development Team
Beta Testers
****
Offline



Posts: 1,269
Location: United Kingdom

None
Re: Adding Global Vars - How do I?
Reply #5 - Sep 28th, 2010 at 12:08am
Post Tools
It works fine for me...

Have you actually uploaded the images to the other directory? The way it works is if it can't find the image, then it will always use the default directory, but if an image with the same name is in the yabb21 directory and the yabb21 template is selected then it will use that image instead... if that makes sense...

Edited:
I think it's because you have a different folder name in each directory - the path and image need to be the same.

This won't work:

default/vista/yourimage.png
yabb21/blue/yourimage.png

This will:

default/vista/yourimage.png
yabb21/vista/yourimage.png

And this:

default/yourimage.png
yabb21/yourimage.png

« Last Edit: Sep 28th, 2010 at 12:30am by Derek Barnstorm »  
Back to top
 
IP Logged
 
Lopa
Junior Member
**
Offline



Posts: 95
Location: Australia
Re: Adding Global Vars - How do I?
Reply #6 - Sep 28th, 2010 at 12:28am
Post Tools
Wow! Global config search for template images throws a new light on what I'm trying to do.  Cheesy

I think my problem is the /vista folder and the two theme scripts using the same var with hard-coded paths. - - - - I think!  Grin

I'll put the "vista" images in the same theme image folders and re-write the vars for a global result.

Will let you know how it goes!

Wink
  

I make mistakes - That's how I learn.
Back to top
WWW  
IP Logged
 
Lopa
Junior Member
**
Offline



Posts: 95
Location: Australia
Re: Adding Global Vars - How do I?
Reply #7 - Sep 28th, 2010 at 8:54pm
Post Tools
Derek Barnstorm wrote on Sep 28th, 2010 at 12:08am:
I think it's because you have a different folder name in each directory - the path and image need to be the same.


I know Derek that the paths must be consistent as in:

/a/vista
/b/vista
/c/vista and so on.  Wink

But what I have done for now is re-write the div's to be more in line with Transitional xhtml dtd and not strict - slapped the whole thing in the .css of each theme and it's all working fine.  So for now if it can be done with .css - that's the way I'll go. Smiley

Thanks for the insight you've given me so far into YaBB - But please stand by as I'm sure I'll be back with even more questions once I sort out how the heck I managed to pick up 2.4 files and mix them with the 2.5AE? I'm supposed to be working with.

Cry Cry Cry

It's all such fun!  Roll Eyes
  

I make mistakes - That's how I learn.
Back to top
WWW  
IP Logged
 
Derek Barnstorm
Support Team
YaBB Next Team
Development Team
Beta Testers
****
Offline



Posts: 1,269
Location: United Kingdom

None
Re: Adding Global Vars - How do I?
Reply #8 - Sep 28th, 2010 at 9:27pm
Post Tools
No worries. Maybe I didn't totally understand what you were trying to do - Have clicked my personal remote to stand by anyhow. Smiley
« Last Edit: Sep 28th, 2010 at 9:29pm by Derek Barnstorm »  
Back to top
 
IP Logged
 
Lopa
Junior Member
**
Offline



Posts: 95
Location: Australia
Re: Adding Global Vars - How do I?
Reply #9 - Sep 28th, 2010 at 9:39pm
Post Tools
What are you like working on nested templates in the .pl files?  Huh
  

I make mistakes - That's how I learn.
Back to top
WWW  
IP Logged
 
Derek Barnstorm
Support Team
YaBB Next Team
Development Team
Beta Testers
****
Offline



Posts: 1,269
Location: United Kingdom

None
Re: Adding Global Vars - How do I?
Reply #10 - Sep 28th, 2010 at 11:16pm
Post Tools
If you can explain exactly what you mean and vision it working, I'll certainly try to help if I can, but making major changes to YaBB is way past me - I consider myself to be nothing more than a 'small time YaBB hacker' who makes simple modifications, but feel free to throw your ideas out and maybe we'll both learn something... Smiley
« Last Edit: Sep 28th, 2010 at 11:17pm by Derek Barnstorm »  
Back to top
 
IP Logged
 
Lopa
Junior Member
**
Offline



Posts: 95
Location: Australia
Re: Adding Global Vars - How do I?
Reply #11 - Sep 29th, 2010 at 12:24am
Post Tools
Hi Derek,

Search.pl is one example of a multi-template file that either uses the same headers and footers, but sometimes uses one header and two footers or vice-versa because all Search templates may use the same file with a different header but the same footer or vice-versa etc.

Also adding the script directly into the file usually gets pretty frustrating because if it's wrong it's really WRONG! and usually breaks everything else. Sad

Using Search.pl as an example, I usually do it like this until I can see that nothing is missing - BUT only for the template I work on at the time because it certainly does make it less confusing than chasing all the other templates mentioned in the file.

I also always use (6) XXXXXX and (6) ZZZZZZ for the simple reason that I use Notepad++ to edit all the files at once with Search and Replace to add the actual script/vars, otherwise one finds oneself endlessly cutting an pasting script as they go along etc. (BORING!)

Something like this.

Code
Select All
<form action="$scripturl?action=search2" method="post" name="searchform" onsubmit="return CheckSearchFields();">
XXXXXX<table width="100%" align="center" border="0" cellpadding="4" cellspacing="1" class="bordercolor" >
	<colgroup>
		<col width="45%" />
		<col width="55%" />
	</colgroup>

_________________________________________________

Though preferably be changed and added like this.

<form action="$scripturl?action=search2" method="post" name="searchform" onsubmit="return CheckSearchFields();">
XXXXXX
<table width="100%" align="center" border="0" cellpadding="4" cellspacing="1" class="bordercolor" >
	<colgroup>
		<col width="45%" />
		<col width="55%" />
	</colgroup>

==========

Blah!

==========
		</td>
	</tr>
</table>ZZZZZZ
</form>


____________________________________

Though preferably be changed and added like this.
		</td>
	</tr>
</table>
ZZZZZZ
</form> 



ExtendedProfiles.pl is a CLASSIC example of nested templates - - - But the rules are for this MOD are:

Wherever the code (ZZZ XXX) is entered the script must start with a <div or <table and end with a /div> or /table>

The exception is if there is a <div class="bordercolor above the <table or the <div then it will more than likely need to added before that.

Post.pl is pretty easy - If you want to join in - Have a play with that and you'll soon get the message as in the pic.
« Last Edit: Sep 29th, 2010 at 12:28am by Lopa »  

yabb-x-z.png ( 3 KB | 98 Downloads )
yabb-x-z.png

I make mistakes - That's how I learn.
Back to top
WWW  
IP Logged
 
Derek Barnstorm
Support Team
YaBB Next Team
Development Team
Beta Testers
****
Offline



Posts: 1,269
Location: United Kingdom

None
Re: Adding Global Vars - How do I?
Reply #12 - Sep 29th, 2010 at 5:07pm
Post Tools
Lopa, I've read that about four times and I have to admit that I'm confused. Aren't the X's and Z's in that pic the effect you were after? Feel free to call me a pomme. Huh

Can you maybe attach the modified files so I can upload them to a test board to see what you mean...
« Last Edit: Sep 29th, 2010 at 5:16pm by Derek Barnstorm »  
Back to top
 
IP Logged
 
Lopa
Junior Member
**
Offline



Posts: 95
Location: Australia
Re: Adding Global Vars - How do I?
Reply #13 - Sep 29th, 2010 at 9:21pm
Post Tools
Derek,

Yeah! it does get confusing? Particularly with me trying to explain it!  Grin

Be free to call me a "Taffy"  Tongue

Example: http://members.iinet.net.au/~cranky65/cgi-bin/forum/YaBB.pl

Have a look at "Help" and it may give you a better idea of what I mean with ZZZ's & XXX's. Because if one starts by dropping code into it, it gets into such a visual mess that's it makes it harder to see where things (tables/divs) start and finish.

Again with nested templates - one may end up with the front end Search looking good - but if it's nested with PM Search also - then it's better to use XXX's etc to determine where the code needs to be changed/added and whether or not one is breaking into something else other than the template one is working on.

But of course - By the time we ever get to CJ's level of experience - we'll wonder why it was ever done like this.  Roll Eyes

« Last Edit: Sep 30th, 2010 at 4:33am by Lopa »  

I make mistakes - That's how I learn.
Back to top
WWW  
IP Logged
 
Derek Barnstorm
Support Team
YaBB Next Team
Development Team
Beta Testers
****
Offline



Posts: 1,269
Location: United Kingdom

None
Re: Adding Global Vars - How do I?
Reply #14 - Sep 30th, 2010 at 4:09am
Post Tools
Yeah, I get what you're doing with the X's and Z's - that does make good sense. But, forgive me for being stupid, what is it that you want to do once you have found all of the places that you want to add the start tags (X's) and end tags (Z's)?

Maybe someone else can jump in here because I'm afraid that still a little puzzled. Undecided

I like what you're doing with the site by the way, I'll be interested to see how it comes along.
« Last Edit: Sep 30th, 2010 at 4:16am by Derek Barnstorm »  
Back to top
 
IP Logged
 
Page Index Toggle Pages: [1] 2 
Topic Tools
 
  « Board Index ‹ Board  ^Top