Page 1 of 1

[SOLVED] Help: News Category Links/Pages

Posted: Mon Jul 21, 2008 6:50 pm
by sam_butler
[Taken to the forum after brief message discussion with Mark!]

Okay, orientation: News template. Here's the issue:

I want my summary templates to display the category as usual, but with the category name as a link to a summary page for *that category only*. Dynamically creating such links is proving to be a nightmare. I know I can create a page with a News call using the category parameter but when I turn the site over to my client they would have to create such a page each time they added a news category, unless I made it static (which would be odd). Hope you're tracking with me so far...

When I use the browsecat param the pretty URLs break down as well, so each category link's URL has a huge and very ugly query string appended. I don't want this, also for security purposes. I would much rather this all be dynamic but I don't know how and can't seem to find the answer.

Over to the community...

Re: Help: News Category Links/Pages

Posted: Wed Jul 23, 2008 5:44 pm
by sam_butler
Still nothing on this? Help would be appreciated.

Re-posted at http://forum.cmsmadesimple.org/index.php/topic,24047.0.html

Re: Help: News Category Links/Pages

Posted: Thu Jul 24, 2008 7:12 pm
by kermit

Code: Select all

// retrieve a news category via url and assign to smarty
// append ?newscat=somecategory or &newscat=somecategory (if already at least one param present)
// to a url, call {thisudt} in that page and can then use category="$newscat" in a news module call
// notes:
// no checking is done, make sure what you append is valid
// should work regardless of pretty url scheme used (see note on ? vs &)
$cat = 'general'; // default if newscat param not present in request uri
if(isset($_GET['newscat'])) $cat = $_GET['newscat'];
$smarty->assign('newscat',$cat);
this does use one of those ugly url parameters, but it's only one...

news template would have something like this for category links:

category|escape:'url'}">{$entry->category}

and then on page 'alias-of-category-summary-page':

{thisudt}
{cms_module module='news' category="$newscat"}

note: not fully tested on things like multiple word categories (should work), multiple categories or wildcard to show child categories (probably not as-is), entities in category names (dunno, didn't check)... but this should get you going.

Re: Help: News Category Links/Pages

Posted: Thu Jul 24, 2008 8:07 pm
by sam_butler
Alright, so I have my site stable at the moment and am working to fill it with copy and photos/graphics so I have a presentable 'release candidate' but I plan to try these things out as soon as I'm a little less busy.

Also, this UDT sounds like a good idea because http://cmsmssite/index.php?foo=bar is much better than http://cmsmssite/index.php/?foobar=foo, ... tplace=yes

That's kinda how ugly it was getting  :P

Thanks for your contribs, I'll report back when I've tested.

Re: [SOLVED] Help: News Category Links/Pages

Posted: Sun Jul 27, 2008 10:33 am
by sam_butler
Parfait dude. Works a treat.  ;D

Thank you very much!