Forums / Cotonti / Skins / Page-specific tpl?

tensh
#1 2009-06-15 15:50
Hi;

Is there a possibility to make a specific page use given TPL for a display, such as it is the case with categories (list.tpl)?
Kilandor
#2 2009-06-15 17:02
Sorry but no the core has no such feature but you could core hack it pretty simply
tensh
#3 2009-06-15 17:38
Thanks for reply, I'll check the possibilities.
Kort
#4 2009-06-15 18:15
You might want to use trunk version of xtemplate.class.php to enable IF-blocks in templates
SED.by - создание сайтов, разработка плагинов и тем для Котонти
tensh
#5 2009-06-15 19:46
Yes... but how would you use the IF block to achieve what I want? Hmm... "if page id=XX"? Then the page.tpl would grow quite big in case of multiple custom pages, and would not be easy to read. :) But yes, thanks for pointing that, it might be a fast solution for little custom pages.
Hodges
#6 2014-04-03 09:53

*bump*

I've tried to implement what Kort has suggested, but I obviously don't know what variables are available in this context. This is my attempt:

	<!-- IF {PHP.page.id} == 22 -->
	<span style="float:right"><a href="index.php?e=page&m=add&c=members">Submit new member</a></span>
	<!-- ENDIF -->

Help! :)

Added 1 hours later:

Also how can I combine this with an if statement to check to see if the user is an admin?

This post was edited by Hodges (2014-04-03 11:06, 9 years ago)
foxhound
#7 2014-04-03 11:49

Maybe this plugin (last post) will be easier to use?

http://www.cotonti.com/forums?m=posts&q=6586&n=unread#unread

<img src="http://www.armaholic.com/datas/thumbs/green-sea-battalion-uniforms-version-03-preview_4.jpg" alt="green-sea-battalion-uniforms-version-03-" />
Twiebie
#8 2014-04-03 12:31
#39366 Hodges:

*bump*

I've tried to implement what Kort has suggested, but I obviously don't know what variables are available in this context. This is my attempt:

	<!-- IF {PHP.page.id} == 22 -->
	<span style="float:right"><a href="index.php?e=page&m=add&c=members">Submit new member</a></span>
	<!-- ENDIF -->

Help! :)

Added 1 hours later:

Also how can I combine this with an if statement to check to see if the user is an admin?

You can do {PHP|dump} in the template to get all the available variables. Make sure debug mode is enabled though.

For your specific statement you could do something like this to check if the user is an admin:

<!-- IF {PHP.pag.page.id} == 22 AND {PHP.usr.isadmin} -->
<span style="float:right"><a href="index.php?e=page&m=add&c=members">Submit new member</a></span>
<!-- ENDIF -->

Here is some good documentation:

http://www.cotonti.com/docs/ext/themes/cotemplate_debug_mode
http://www.cotonti.com/docs/ext/themes/cotemplate_statements

This post was edited by Twiebie (2014-04-03 12:57, 9 years ago)
Kort
#9 2014-04-03 12:39

That should be:

<!-- IF {PHP.pag.page_id} == 22 AND {PHP.usr.isadmin} -->
<span style="display:block; float:right"><a href="{PHP|cot_url('page','c=members&m=add')}">Submit new member</a></span>
<!-- ENDIF -->

not

{PHP.page.id}

 

SED.by - создание сайтов, разработка плагинов и тем для Котонти
This post was edited by Kort (2014-04-03 12:53, 9 years ago)
Hodges
#10 2014-04-03 13:46

Works perfectly. Thanks guys for the swift replies!