cfg file in 2.2

All style (template, theme and imageset) related questions for the new release; advice, feedback here please.
Post Reply
User avatar
Arty
Former Team Member
Posts: 985
Joined: Wed Mar 06, 2002 2:36 pm
Location: Mars
Contact:

cfg file in 2.2

Post by Arty »

Glad there is a special section for styling in 2.2
Here is my first question:

Will there be a cfg file that can be executed on theme initialization?

Something like subSilver.cfg in 2.0. It is very handy to add own tpl variables and switches based on current user status.

I'm using it in 2.0 to check if top images exist for current language and also i use it to set custom template variables to avoid editing lots of tpl files when change is needed.

I think it would be a very nice feature for 2.2

P.S. i submitted this request to tracker on sourceforge.

User avatar
dhn
Registered User
Posts: 1518
Joined: Wed Jul 04, 2001 8:10 am
Location: Around the corner
Contact:

Re: cfg file in 2.2

Post by dhn »

Styles in 2.2 work different now that in 2.0.x and the system is a lot more elaborate. You will like to hear, and I guess this is very helpful in what you want to do, that it is now possible to include external pages into your templates.

Code: Select all

<!-- INCLUDE custom_text.html -->
The above will e.g. include the contents of the file custom_text.html in which template variables can be used.

Much more interesting is the logic you are able to use now inside templates:

Code: Select all

<!-- IF ADMIN -->Some HTML only an admin will see<!-- ENDIF -->
The above will show the text in between the if statement only to admins. You can even extend it like this:

Code: Select all

<!-- IF ADMIN -->
    Some HTML only an admin will see
<!-- ELSE -->
    <!-- INCLUDE custom_text.html --> This will only be seen by non-admins
<!-- ENDIF -->
There are 2.0.x like cfg files for the imagesets but I don't know if they will or can be used the same way. But I doubt you will need this trick anyway with the options you now have. 8)
Image

User avatar
Arty
Former Team Member
Posts: 985
Joined: Wed Mar 06, 2002 2:36 pm
Location: Mars
Contact:

Re: cfg file in 2.2

Post by Arty »

Feature to include html files is good, but sometimes it is too much.

I need to use custom tpl variables for every table header and footer in hi-tech themes and including lots of html files (that would be 3 files per table - one for header before table title, one for header after title, one for footer) will slow down template a lot.

Also in some templates i need to repeat lot of same color values inside tpl files (color values for mouseover and mouseout events - this can't be done via css because changing cell class works awfully slowly on all browsers). When that colors needs to be changed it can be done by editing lots of tpl files and replacing all values - it will take only a minute. But it will take a minute for me, but for user it might take an hour to customize colors in theme. Much faster would be for user to replace one color value in cfg file.

So i think this would be a very nice feature to allow designers to use custom variables in templates.

User avatar
dhn
Registered User
Posts: 1518
Joined: Wed Jul 04, 2001 8:10 am
Location: Around the corner
Contact:

Re: cfg file in 2.2

Post by dhn »

I just checked and it seems that the imageset cfg file is just there for initial installation. Later all the image related data is handled by the database. So you won't be able to use them for your workaround.

I guess you'd need to wait for a more involved person to tell you if custom variables are planned or/and if they are possible already with the current template engine.
Image

User avatar
Arty
Former Team Member
Posts: 985
Joined: Wed Mar 06, 2002 2:36 pm
Location: Mars
Contact:

Re: cfg file in 2.2

Post by Arty »

I really need that feature, but it isn't there.

It takes only few minutes to add it. I even wrote all code so you could easily do it (code is based on 30 minutes old cvs).

in include/template.php find this (lines 84 and 85 in current cvs):

Code: Select all

$this->static_lang = $static_lang;
		$this->force_recompile = $force_recompile;
Then if you agree to add feature to execute cfg file you need to add this code:

Code: Select all

if (file_exists($this->root . '/style.cfg'))
		{
			@include($this->root . '/style.cfg');
		}
It will execute style.cfg if it exists.


If you think that allowing to run php file might be dangerous (though i think its not the issue because it was working fine in 2.0 and noone ever had any security issues with it) then that cfg file can contain only list of custom variables in format "variable_name=value" (one variable per line).
In that case you need to add this code (same place as previous code - after line 85):

Code: Select all

if (file_exists($this->root . '/style.cfg'))
		{
			$file = @file($this->root . '/style.cfg');
			$vars = array();
			for($i=0; $i<count($file); $i++)
			{
				$item = explode('=', $file[$i], 2);
				if(count($item) == 2)
				{
					$vars[$item[0]] = $item[1];
				}
			}
			if(count($vars) > 0)
			{
				$this->assign_vars($vars);
			}
		}

Please add one of those codes or something similar.



Also there is a bug in template initialization. It was there long time ago, but it still isn't fixed: template variables {T_TEMPLATE_PATH} and {T_IMAGESET_PATH} are initialized incorrectly. With current variable {T_TEMPLATE_PATH} for subSilver is "styles/subSilvertemplate" and {T_IMAGESET_PATH} for subSilver is "styles/subSilverimageset".

Here is current code (in includes/functions.php):

Code: Select all

'T_TEMPLATE_PATH'		=> 'styles/' . $user->theme['primary']['template_path'] . 'template', 
'T_IMAGESET_PATH'		=> 'styles/' . $user->theme['primary']['imageset_path'] . 'imageset',
and here is fixed code:

Code: Select all

'T_TEMPLATE_PATH'		=> 'styles/' . $user->theme['primary']['template_path'] . '/template', 
'T_IMAGESET_PATH'		=> 'styles/' . $user->theme['primary']['imageset_path'] . '/imageset',

User avatar
Arty
Former Team Member
Posts: 985
Joined: Wed Mar 06, 2002 2:36 pm
Location: Mars
Contact:

bump

Post by Arty »

its been more than a week and no replies, so i guess it is appropriate to bump...

are you even considering adding this feature?
and could you please fix bug in functions.php - without it {T_TEMPLATE_PATH} is useless.

User avatar
haravikk
Registered User
Posts: 292
Joined: Sun Apr 20, 2003 5:05 pm
Contact:

Re: cfg file in 2.2

Post by haravikk »

I think I heard that you can include php in templates, or include a full .php file. Would doing this in your header have the desired result do you think?
Images in sigs! please.

User avatar
psoTFX
Registered User
Posts: 1984
Joined: Tue Jul 03, 2001 8:50 pm
Contact:

Re: cfg file in 2.2

Post by psoTFX »

I've not responded because at this moment what is discussed here is of no immediate/significant priority for us. I will address the issues raises at some future point.

User avatar
Arty
Former Team Member
Posts: 985
Joined: Wed Mar 06, 2002 2:36 pm
Location: Mars
Contact:

Re: cfg file in 2.2

Post by Arty »

Thanks.

mm3guy
Registered User
Posts: 34
Joined: Tue Sep 02, 2003 7:25 pm

Re: cfg file in 2.2

Post by mm3guy »

I think this new template system is awsome! 8)

Post Reply