Cotonti / Open Source PHP Content Management FrameworkContent Management Framework

Forumlar / Cotonti / Core Labs / page templates idea

#1 2011-11-01 20:40

If you do this (see below), it is very simple to make a separate TPL for a single page. based on the Alias.. This is a very minimal addition, but gives a great freedom with designing. I now have a page.[pagealias].tpl which i can use to design one single page :)

require_once $cfg['system_dir'] . '/header.php';

$mskin = sed_skinfile(array('page', $pag['page_alias'], $sed_cat[$pag['page_cat']]['tpl']));
$t = new XTemplate($mskin);

Hope this will help someone.. By the way it can be found in line 161 (around)

==- I say: Keep it EZ -==
#2 2011-11-01 23:06
With the ability to parse HTML through page text I find this kind of situational for most people. For most cases having a separate tpl per category is ideal... But, good work!
We are what we repeatedly do. Excellence then, is not an act, but a habit.
#3 2011-11-02 07:14

ez: nice suggestion. i'd say it is far better than playing with alias-based conditions in a category tpl. in general, balancing between the number of templates and their "readability" depends on the project requirements and the skinmaker style, so i'm afraid there is no such thing as "ideal" here. - создание сайтов, разработка плагинов и тем для Котонти
#4 2011-11-02 09:39

@Dyllon: Its not about the page text, its about layouting the complete page  (So all fields...)

@Kort: Thanks, I think all designers will like this one... ?

I havent tried it YET with the page.edit.... stuff yet, But i can imagine that designers want to have that there too.. e.g. A FIXED page that should not have the Alias field and the delete option.  (This to prevent the client to either delete the page, or change the alias.... or any other fixed field.... )

==- I say: Keep it EZ -==
#5 2011-11-02 11:50

I like your idea. Especially for 'system' pages this will be useful. Using page_text to insert the HTML is very dirty, inefficient and limited, so the addition of custom tpl files for individual pages is welcome.

Your implementation won't work (correctly), because it will break category tpl files. cot_tplfile will look for a template file matching page.myalias.mycategory.tpl, will probably fail, try page.myalias.tpl, maybe fail and finally return page.tpl. It will never look for page.mycategory.tpl anymore. You need an alternative approach. Try this:

if ($pag['page_alias'])
	$alskin = cot_tplfile(array('page', 'al-'.$pag['page_alias']));
	if (!strpos($alskin, ''.$pag['page_alias'])) $alskin = '';
$mskin = ($alskin) ? $alskin : cot_tplfile(array('page', $cat['tpl']));
$t = new XTemplate($mskin);

Note that this is Siena code, not Genoa like yours, so you'll need to adapt it a little. I've also added the prefix al- to the filename to avoid confusion with category tpl files.

#6 2011-11-02 17:55

I think its good idea for little plugin))) - мой маленький зарождающийся блог о котонти.
снижение стоимости программирования и снижение стоимости производства разные вещи. Первое можно скорее сравнить с раздачей работникам дешевых инструментов, чем со снижением зарплаты
#7 2011-11-02 18:01

Thanks you all, it was a very fast idea..., and yes i do know that the code will break down, and that it was not perfect.... But this was all about the idea, and that came through, so mission accomplished (for my part). Now just the correct code is needed, but that can be developped fast i think....

==- I say: Keep it EZ -==
#8 2013-09-27 22:50

Pfff, I've had this problem with several client websites where I wanted to use the system category for multiple pages with different TPL's.

Glad I stumbled upon that bit of code, guys!


#9 2013-09-29 20:47
#38050 Twiebie:

Pfff, I've had this problem with several client websites where I wanted to use the system category for multiple pages with different TPL's.

Glad I stumbled upon that bit of code, guys!


Make a simple plugin. hook it on `page.main`. Code it as follows:

if ($cat['tpl'] == 'system') {
  $mskin = cot_tplfile(array('page', $cat['tpl'], empty($al) ? $id : $al));

use templates named as: `page.system.#alias.tpl` or `page.system.#id.tpl`  (where #alias and #id is alias or id of corresponding page), located in standard page.tpl folders.

Note1: be sure to use alias if it exists for current page
Note2: be sure not to use special symbols in page alias that can not be used as file name symbols
правильный хостинг —
#10 2013-09-29 23:34

I already did just that a few days ago haha. :)

Here's the plugin if anyone needs it:

#11 2013-12-02 22:23

nice nice

<a href=""></a>