Форуми / Cotonti / Core Labs / page templates idea

ez
#1 01.11.2011 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 page.inc.php line 161 (around)

==- I say: Keep it EZ -==
Dyllon
#2 01.11.2011 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.
Kort
#3 02.11.2011 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.

SED.by - создание сайтов, разработка плагинов и тем для Котонти
ez
#4 02.11.2011 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 -==
GHengeveld
#5 02.11.2011 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, 'page.al-'.$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.

esclkm
#6 02.11.2011 17:55

I think its good idea for little plugin)))

littledev.ru - мой маленький зарождающийся блог о котонти.
снижение стоимости программирования и снижение стоимости производства разные вещи. Первое можно скорее сравнить с раздачей работникам дешевых инструментов, чем со снижением зарплаты
ez
#7 02.11.2011 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 -==
Twiebie
#8 27.09.2013 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!

Thanks.

Macik
#9 29.09.2013 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!

Thanks.

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

https://github.com/macik
правильный хостинг — https://goo.gl/fjCa1F
Twiebie
#10 29.09.2013 23:34

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

Here's the plugin if anyone needs it: http://www.cotonti.com/datas/users/pagetpl_897.zip

singh336
#11 02.12.2013 22:23

nice nice

<a href="http://www.streetlegalmods.com/">http://www.streetlegalmods.com/</a>