Switch Theme:
Navigation
Login
Who\ Guests: 4
Members: None
Shoutbox
Characters Remaining:


susie
Aug 16, 7:08 PM
thanks for these modules! awesome!
Feb 24, 4:02 PM
Story End module link is fixed.
Jan 10, 2:01 AM
The Story's End mod for eFic 3.X links to the index.
Dec 25, 4:12 PM
huhum hier is belara, im from germany ^^
Guest
Dec 25, 4:12 PM
HuHu Belara!!!

Articles : eFiction : Fun with Variables.php

The variables.php files can have a number of uses in your skin. First, you can use it to override any number of settings in the blocks. For instance, let's assume you've decided that you've set most of the blocks to be index only. Now say that some of your site visitors are asking you for the main categories to be visible on all the pages and not just the index page. You don't want to redesign all your skins. Instead you'll design a new skin with the categories visible on all pages and see what kind of feedback you get from your visitors. You decide that this new skin will have a column on the left with the categories block in it. So you need to change where the categories block will be displayed for this skin (and this skin only). The solution is to create a variables.php file for the skin like so:

<?php
$blocks['categories']['status'] = 1;
?>

Setting the status to 1 will cause the categories block to be displayed on all pages for that skin ONLY. A status of 0 is totally off. If you're not using a block, turn it off. It will help with your site's performance. A block with a status of 1 is displayed on all pages. A block with a status of 2 is displayed only on the index page. I know it might be tempting to just set all the blocks to display on all the pages, but you're going to slow your site's performance down when you do that. If you're converting a skin from 1.1 to 2.0 or if you're just more comfortable doing your blocks as they were in 1.1, you can set the following in your variables.php to have most of the blocks behave as they did in 1.1.

$blocks['categories']['tpl'] = 1;
$blocks['recent']['tpl'] = 1;
$blocks['featured']['tpl'] = 1;
$blocks['random']['tpl'] = 1;
$blocks['info']['style'] = 2; 

The info block is where the {totalstories} and {totalauthors} variables went in 2.0. If no style is set it will output in a tabular format. If style 1 is chosen it will output as a narrative. And style 2 is the variables themselves, i.e. {totalstories} and {totalauthors}. In 2.0, {totalauthors} is actually the total number of authors. You can use {totalmembers} for the number of members your site has. I haven't gotten the news block configured this way yet. It's on my list of things to do though.

You can also override the title of the block. For instance, by default the random story title is "Story of the Moment" and it works for most of your skins, but getting back to our example, this new skin you're making the text is wrapping around and you don't like that. You could change the title of the block to "Random Story":

$blocks['random']['title'] = "Random Story";

You could even force the title of that one block to be a smaller text size:

$blocks['random"]['title'] = "<span style='font-size: 9pt;'>Random Story</span>";

Or even make it a graphic:

$blocks['random']['title'] = "<img src='skins/MYSKIN/images/RandomStoryTitle.gif' alt='Random Story'>";

Of course there's no reason you couldn't just do those in your index.tpl with plain old text/html, but I'm just trying to give you ideas.

You can also override many of the default graphics using the variables.php file. If you continue the example of creating a new skin, let's assume you've decided to make it a yellow theme. You might have problems with the yellow star and half-star showing up on the yellow background you've chosen. In variables.php, you can set a different graphic to represent the star and half-star. As an example, look at the Romance skin that came with the script. There the stars are hearts. In the Romance skins' variables.php you'll find:

$star = "<img src=\"skins/Romance/images/sm_heart.gif\" alt=\"heart\">";
$halfstar = "<img src=\"skins/Romance/images/sm_heart.gif\" alt=\"half heart\">";

If you have chosen the like/dislike rating system. You would use $like and $dislike instead of $star and $halfstar. You can also change the graphics for featured and past featured stories from the blue and red ribbon to something of your choice. In that case you would use $featured and $retired.

If you have links you wanted added to the menu block or available to the .tpl as variables you can add them here like this:

$pagelinks['forum'] = "<a href=\"forum/index.php\">Forums</a>";

This will give you the variable {forum} to use in your skin for that link.  Note: the same format works to add the links universally to all skins by placing it in the func.pagemenu.php file.  To then add this extra link to the menu block you'd need to add it to the content list:

$blocks['menu']['content'] = array(
	0 => 'home', 
	1 => 'members', 
	2=> 'search', 
	3 => 'tens', 
	4 => 'help', 
	5 => 'forum', 
	6 => 'login', 
	7 => 'logout', 
	8 => 'adminarea');

The menu block is set up in such a way that you can add additional menus.   It's an undocumented trick because I haven't got an admin panel built for it yet.  Still working on the logistics.  However, on several of my skins you might have noticed the secondary "Browse by:" menu.  Here's the trick in variables.php that makes it work.

$blocks["menu2"] = array(
	"title" => "Browse by: ",
	"status" => "1",
	"file" => "menu/menu.php", 
	"style" => 1, 
	"content" => array (
		0 => 'recent', 
		1=> 'titles', 
		2 => 'catslink',
		3 => 'series', 
		4 => 'authors', 
		5 => 'challenges'
	)
);

Note the indenting in the above two examples is optional, I just showed it that way so it would be easier to read.  The code above creates a new block named "menu2" with a title of "Browse by: ".  The file for the block is the same as the standard menu block.  Then we set the style to 1 in this case, so it displays as a list of links rather than in an unordered list.  Finally, we define what links we want in our menu.

You can also use variables.php to create your own variables for your skin.  Let's use the MakeaWave skin for example.  The time and date in the upper right hand corner are created by a variable set in variables.php.

$tpl->assignGlobal("today", date("F j, Y g:i:s a"));

Then in the header.tpl of the skin I include the variable {today} where I want the date and time to be displayed.

The variables.php file makes a huge number of things possible and I've really only touched the surface.
 

Print Print this page
E-mail E-mail to me

Recommend this Recommend this
Digg This!
Delicious Bookmark this on Delicious

Ratings

star0 0% 0 No votes
starstar0 0% 0 No votes
starstarstar0 0% 0 No votes
starstarstarstar0 0% 0 No votes
starstarstarstarstar0 0% 0 No votes
You must login to rate this.

Comments

Post Your Comment

Warning! Javascript must be enabled for this function to work properly.