Page 1 of 1

Passing a parameter in a cms_selflink [solved]

Posted: Tue Aug 03, 2010 11:21 am
by triggersmith
I'm sure this is very simple but I can't work it out.

Let's say I have a page where I have buttons that relate to to different news categories.

News about dogs

News about cats

News about sheep


I have a news page "mynews"

with the tag {news category=x}

So when the user clicks on "News about dogs" I have a cms_selflink to mynews passing the parameter "Dogs" as x.

I hope this makes sense.

Thanks

Re: Passing a parameter in a cms_selflink

Posted: Tue Aug 03, 2010 12:51 pm
by NaN
Why not creating a page for each category and use cms_selflink to link to that page?
In this page you can use the page alias as news category:

{news category=$content_alias}

You could also use the browsecat param to list news catgories.
Each category will be a link that displays news articels of  the selected category.

Another solution could be the param "urlparam" of the cms_selflink:

{cms_selflink page="mynews" urlparam="category=..."}

This will link to your news page with an additional variable "category".
You now can call your news like this:

{news category=$smarty.get.category}

Re: Passing a parameter in a cms_selflink

Posted: Tue Aug 03, 2010 10:15 pm
by triggersmith
Thanks for your reply.

I realise I can have a page for each category but I am expecting to have 50, 100 or even more news categories.  It seems a bit silly to have that many pages with the only difference being the category.  There has to be a more elegant way of doing it.

I don't want to use the browse category option because I want the main page to be a business logo with a direct link to their news (category).

I will try you other suggestion and report back.

As an aside there seems to be soo many features of CMS MS (which I love BTW) that have very little info on how to use them, examples etc.

Like for instance the additional page parameters which I though may have been a solution here.

Thanks again, I'll get back.
Paul

Re: Passing a parameter in a cms_selflink

Posted: Tue Aug 03, 2010 11:45 pm
by triggersmith
OK I think I have this nearly working but I think there is a syntax problem or something.

This is my tag

{cms_selflink page="partner-news-detail"  urlparam="category=Horses NZ" text="news"}

When I click on the news link in my browser it can't find the page.  Here is the url I get:

http://mywebsite.co.nz/index.php?page=p ... orses%20NZ

It's like there is a separator missing between the page name and the param.

What have I done wrong here.

Thanks

Re: Passing a parameter in a cms_selflink

Posted: Tue Aug 03, 2010 11:46 pm
by calguy1000
urlparam='?foo=bar'

Re: Passing a parameter in a cms_selflink

Posted: Wed Aug 04, 2010 12:03 am
by triggersmith
calguy1000 wrote: urlparam='?foo=bar'
I worked it out actually

urlparam="&foo=bar"

worked.

I presume following this syntax I could string a bunch of parameters like this:

urlparam="&param1=x&param2=y"

etc?

Yes I can have just tried this...awesome!!!!