Page 1 of 1
[Solved] Display something only if page alias LIKE ?
Posted: Tue Oct 28, 2008 5:30 am
by xmas3
Hi all,
Im trying to write a condition, that shows something (menu, text) only if page-alias contains some text/preffix.
Something similar as you can use in sqls LIKE '%bob%' .
Is it possible to do it with smarty?
I tryied
in my page template but doesnt work.
Any suggestions?
Thanks a lot,Miro
Re: Display something only if page alias LIKE ?
Posted: Tue Oct 28, 2008 8:10 am
by alby
xmas3 wrote:
Im trying to write a condition, that shows something (menu, text) only if page-alias contains some text/preffix.
Something similar as you can use in sqls LIKE '%bob%' .
In MenuManager you can use include/exclude extension
Alby
Re: Display something only if page alias LIKE ?
Posted: Tue Oct 28, 2008 8:27 am
by xmas3
Yes, of course, but what if I would like show other components (static text, banners etc.) only on selected pages having some predefined text in page-alias? Hmm?
M.
Re: Display something only if page alias LIKE ?
Posted: Tue Oct 28, 2008 8:48 am
by alby
xmas3 wrote:
Yes, of course, but what if I would like show other components (static text, banners etc.) only on selected pages having some predefined text in page-alias? Hmm?
No, for this you must change module sql code for = to LIKE behaviour
Alby
Re: Display something only if page alias LIKE ?
Posted: Tue Oct 28, 2008 11:30 am
by xmas3
Im not sure what you are talking about...
Where should I change it?
M.
Re: Display something only if page alias LIKE ?
Posted: Tue Oct 28, 2008 11:41 am
by nhaack
You could do it with smarty though.
Code: Select all
{if $page_alias|truncate:5:"" == "show_"}
...
MY CODE
...
{/if}
What this code will do in your template is the following: It will limit the alias to the first 5 characters. If our alias is "articlename", the variable will contain: "artic". If our alias has a prefix like "show_articlename", the variable will contain "show_". It then compares these first characters of the alias string with a defined string. If that is equal it does something.
If you want to use another prefix, state the character length behind truncate and state the desired prefix where you read "show_".
Hope this could solve your issue...
Best
Nils
Re: Display something only if page alias LIKE ?
Posted: Tue Oct 28, 2008 12:02 pm
by xmas3
Great, thats what Ive been looking for.
Thanks a lot.
M.