[solved]Add tags 2 template for specific pages/exclude pages
[solved]Add tags 2 template for specific pages/exclude pages
Hi
My template applies to most of my site
On some pages I have put in the content section dynamic content tags like {news} and {FormBuilder form='contact'} for the contact form and news summary which I don't want to be editable by my client, and I don't want them to appear on every page, just on specific pages.
So should I create a copy of my template for each page with these kinds of items and edit each accordingly? or just tell the user not to delete the tags... or is there a simple way in which I can insert the tags into the main template and have them only appear on specified pages?
My template applies to most of my site
On some pages I have put in the content section dynamic content tags like {news} and {FormBuilder form='contact'} for the contact form and news summary which I don't want to be editable by my client, and I don't want them to appear on every page, just on specific pages.
So should I create a copy of my template for each page with these kinds of items and edit each accordingly? or just tell the user not to delete the tags... or is there a simple way in which I can insert the tags into the main template and have them only appear on specified pages?
Last edited by ladyr0gue on Sun Apr 22, 2012 2:19 pm, edited 3 times in total.
Re: Is there a way to add tags to template for specific page
Unless I have some very specific need for multiple templates, I usually use one template with some smarty logic to identify the page (either by alias, by parent or by a smarty variable the page editor can set from the page editor itself). So I just have to check if a condition is met to show or not some section of content.
"There are 10 types of people in this world, those who understand binary... and those who don't."
* by the way: English is NOT my native language (sorry for any mistakes...).
Code of Condut | CMSMS Docs | Help Support CMSMS
My developer Page on the Forge
GeekMoot 2015 in Ghent, Belgium: I was there!
GeekMoot 2016 in Leicester, UK: I was there!
DevMoot 2023 in Cynwyd, Wales: I was there!
* by the way: English is NOT my native language (sorry for any mistakes...).
Code of Condut | CMSMS Docs | Help Support CMSMS
My developer Page on the Forge
GeekMoot 2015 in Ghent, Belgium: I was there!
GeekMoot 2016 in Leicester, UK: I was there!
DevMoot 2023 in Cynwyd, Wales: I was there!
Re: Is there a way to add tags to template for specific page
you can use the permissions system for this.
remove the "manage all content" permission from the user group of the editor, and manually add the editor on every page he is allowed to edit, but not on the page with the tags.
remove the "manage all content" permission from the user group of the editor, and manually add the editor on every page he is allowed to edit, but not on the page with the tags.
Re: Is there a way to add tags to template for specific page
Thanks for your replies,
I think I need to use the first option as I want the user to be able to edit content on those pages, just not to accidentally delete the tags. On other pages in the same div we may wish to add editable content.
Please can you tell me how I should specify page alias/es in my template, for example to make the {news} summary to appear on pages alias1 and alias2?
Thanks
I think I need to use the first option as I want the user to be able to edit content on those pages, just not to accidentally delete the tags. On other pages in the same div we may wish to add editable content.
Please can you tell me how I should specify page alias/es in my template, for example to make the {news} summary to appear on pages alias1 and alias2?
Thanks
Re: Is there a way to add tags to template for specific page
To get the current page alias use {$page_alias}
I saw someone post this code snippet which I believe should work:
I saw someone post this code snippet which I believe should work:
Code: Select all
{if page alias="news"}
{news browsecat=1} {* this may be any content you wish *}
{else}
{menu} {* this may be any content you wish *}
{/if}
"There are 10 types of people in this world, those who understand binary... and those who don't."
* by the way: English is NOT my native language (sorry for any mistakes...).
Code of Condut | CMSMS Docs | Help Support CMSMS
My developer Page on the Forge
GeekMoot 2015 in Ghent, Belgium: I was there!
GeekMoot 2016 in Leicester, UK: I was there!
DevMoot 2023 in Cynwyd, Wales: I was there!
* by the way: English is NOT my native language (sorry for any mistakes...).
Code of Condut | CMSMS Docs | Help Support CMSMS
My developer Page on the Forge
GeekMoot 2015 in Ghent, Belgium: I was there!
GeekMoot 2016 in Leicester, UK: I was there!
DevMoot 2023 in Cynwyd, Wales: I was there!
Re: Is there a way to add tags to template for specific page
If you are going to be putting the modules calls, {news}, in the same place on every page but want to let the editor change content in Content: box you can...
{content block='modules' label='This box is for module calls only, no other text etc.' oneline='true'}
This will give you a one line edit box you can put the module call in...
This box is for module calls only, no other text etc.:
[ {FormBuilder form='contact'} ]
Pretend there is an edit box around the formbuilder call
...
{content block='modules' label='This box is for module calls only, no other text etc.' oneline='true'}
This will give you a one line edit box you can put the module call in...
This box is for module calls only, no other text etc.:
[ {FormBuilder form='contact'} ]
Pretend there is an edit box around the formbuilder call

Re: Is there a way to add tags to template for specific page
oh fantastic, thanks, will try that. The prevous solution didn't work for me (though thanks for the reply) and this one was more what I was looking for 
edit: Yes, can confirm that works a treat, thanks again

edit: Yes, can confirm that works a treat, thanks again

Re: [solved] how to add tags to template for specific pages?
Just one thing - I noticed that using the actually seems to mean that the page loads the module every time - which on pages like news and contact means that in certain situations it gets doubled up - eg. as news is the default page to display detail when you click on category you get title>categories>summary articles and then the module is called again so title>categories>number of articles called. And on contact page I noticed that this becomes a problem too when you fail to enter all the required fields the contact from reloads in the same page but with another below it. This doesn't happen when you enter the module call into a normal content block, it all beganves as it should. so maybe I'll try creating a oneline content block and labelling it to not be edited 
Code: Select all
{content block='modules' label='This box is for module calls only, no other text etc.' oneline='true'}

Re: how to add tags to template for specific pages?
Ok what I have decided to do now is to have the news module tag in the template so that it appears in the sidebar of every page - the only thing is i would like to have it not appear on the actual News page as of course that page contains the detail view so doesn't need the summary view. have tried excludeprefix but it doesn't like it. How do I create a tag that calls a module in every page except specific aliases? I tried replacing the {news} tag (which works) with a modification of the code Jo found for me...
but again it didn't work - I get the error

toJo Morg wrote: {if page alias="news"}
{news browsecat=1} {* this may be any content you wish *}
{else}
{menu} {* this may be any content you wish *}
{/if}
Code: Select all
{if page alias="news"}
{content block="some content"}
{else}
{news}
{/if}
so can anyone please tell me how to get a news module how to show up on every page but one without adding it to each page manually?string(114) "Smarty error: [in tpl_body:23 line 6]: syntax error: unidentified token '=' (Smarty_Compiler.class.php, line 1410)"
Parse error: parse error in C:\xampp\htdocs\cmsms\tmp\templates_c\%%01^013^01360D26%%tpl_body%3A23.php on line 13

Re: Add tags to template for specific pages/ exclude pages
have also tried
which doesn't throw up any errors, but it doesn't work exactly - news summary still displays on the news page and while this code adds a box named 'some content', it's on every page not just news - and content put in this box doesn't display.
has kinda the opposite effect -the 'some content' clock appears on every page and shows up, but no news anywhere! I think I'm getting closer.. but would appreciate some pointers 
Code: Select all
{if $page_news}
{content block="some content"}
{else}
{news}
{/if}
Code: Select all
{if page_news}
{content block="some content"}
{else}
{news}
{/if}

Re: Add tags to template for specific pages/ exclude pages
I didn't saw this before: there was a typo on my sample....
should be
I apologize for that... 
IIRC $page_alias should exist on all page templates.
About your sample: {if $page_news} tests if $page_news is True;
You can also test for isset to check if the var exists at all (which, AFAIK, would fail a simple true false test).
Code: Select all
{if page alias="news"}
Code: Select all
{if $page_alias="news"}

IIRC $page_alias should exist on all page templates.
About your sample: {if $page_news} tests if $page_news is True;
You can also test for isset to check if the var exists at all (which, AFAIK, would fail a simple true false test).
"There are 10 types of people in this world, those who understand binary... and those who don't."
* by the way: English is NOT my native language (sorry for any mistakes...).
Code of Condut | CMSMS Docs | Help Support CMSMS
My developer Page on the Forge
GeekMoot 2015 in Ghent, Belgium: I was there!
GeekMoot 2016 in Leicester, UK: I was there!
DevMoot 2023 in Cynwyd, Wales: I was there!
* by the way: English is NOT my native language (sorry for any mistakes...).
Code of Condut | CMSMS Docs | Help Support CMSMS
My developer Page on the Forge
GeekMoot 2015 in Ghent, Belgium: I was there!
GeekMoot 2016 in Leicester, UK: I was there!
DevMoot 2023 in Cynwyd, Wales: I was there!
Re: Add tags to template for specific pages/ exclude pages
Thank you for your reply, but oh dear, I still seem to be failing!
displays the 'some content' content block on every page and no display of news
and smarty error
Code: Select all
{if $page_alias="news"}
{content block='some content'}
{else}
{news number="1"}
{/if}
and smarty error
Code: Select all
string(114) "Smarty error: [in tpl_body:23 line 6]: syntax error: unidentified token '=' (Smarty_Compiler.class.php, line 1410)"
Re: Add tags to template for specific pages/ exclude pages
Try using single quotes 'news' in the if page alias=...
Re: Add tags to template for specific pages/ exclude pages
Thanks for keeping up with me on this!
that gives me a smarty error on the news page
that gives me a smarty error on the news page
and the same thing. tried the simple quotes on the content block and in the news tag but no - it just doesn't like the '='string(114) "Smarty error: [in tpl_body:23 line 7]: syntax error: unidentified token '=' (Smarty_Compiler.class.php, line 1410)"
