Page 1 of 1
News module pretty urls
Posted: Tue Apr 30, 2013 12:09 pm
by zimmo
I am trying to work out how the news module links can look pretty. When you have a limit on the number of items per page and you get the page navigation, the pretty urls dont apply on the next page links.
You are presented with dynamic urls rather than pretty urls.
Is there something you can do to fix this.
I have again tried to google for an answer with no luck.
So instead of the next page link looking like this:
index.php?mact=News,m4329d,default,1&m4329dnumber=6&m4329dpagenumber=2&m4329dreturnid=59&page=59
Would be better to have something like:
news-2.html
Many thanks
Barry
Re: News module pretty urls
Posted: Wed May 01, 2013 7:49 pm
by Dr.CSS
If you enable true pretty URLs they will come out like, site.com/1/15/name-of-article.html, 1 being the article number and 15 being the page ID, that's it...
Guess it helps to read and comprehend all of the post, what Wishbone says...
I use cycle to make pagination (X amount of articles per cycle)...
http://vobuzzweekly.com/blog.html
Re: News module pretty urls
Posted: Wed May 01, 2013 9:26 pm
by Wishbone
Not for next and prev links

CG says 'not gonna happen'
Re: News module pretty urls
Posted: Thu May 02, 2013 5:13 am
by Gregor
[Off topic]Would you mind explaining how you made the archive on the frontpage. Looks very nice![/Off topic]
Re: News module pretty urls
Posted: Thu May 02, 2013 5:36 am
by Wishbone
He's loading all the posts at once, and using a jQuery slider to show them. Very nice!
Re: News module pretty urls
Posted: Thu May 02, 2013 5:58 am
by Gregor
Higher cmsms magic

Re: News module pretty urls
Posted: Fri May 03, 2013 10:37 pm
by manuel
Dear Dr.CSS,
Great tip!!
I've just finished implementing a cycle2 powered pagination on my latest project, I don't know if i'll ever be able to return to regular pagination
Greetings,
Manuel
Re: News module pretty urls
Posted: Mon May 06, 2013 8:18 pm
by Dr.CSS
@Gregor or anybody else interested...
Not sure what part you are referring to but you may find the answer here, if not let me know and I will make one...
http://how-i-did-that.com/
Re: News module pretty urls
Posted: Mon May 06, 2013 8:26 pm
by Gregor
@Dr. CSS Thanks for your link. I will go through the code and example. If I have any questions I'd like to get back to you. Many thanks.
Re: News module pretty urls
Posted: Mon May 20, 2013 1:15 pm
by psy
Nice Dr CSS
Here is my solution to the problem. It's a bit clunky and doesn't give you pretty URLs but it does give you clickable page numbers and saves on download time if you have lots of articles.
Code: Select all
{strip}
{if !isset($smarty.session.pagecount)}
{session_put var=pagecount value=$pagecount}
{else}
{assign var=pagecount value=$smarty.session.pagecount}
{/if}
{if $pagecount gt 1}
{capture assign=pagenumbering}
{assign var=num value=1}
{if !empty($smarty.get.cntnt01start)}
{assign var=currentpage value=$smarty.get.cntnt01start/$param_pagelimit}
{else}
{assign var=currentpage value=1}
{/if}
<ul class="pagination">
<li class="arrow {if $current lt $pagelimit} unavailable{/if}">
<a href="{module_action_link module='News' action='default' urlonly=1 category='Articles' start=$goto pagelimit=$param_pagelimit}">
«
</a>
</li>
{for $foo=1 to $pagecount}
{if $num gt $pagecount}{break}{/if}
<li {if ceil($currentpage) eq $foo}class="current"{/if}>
{assign var=goto value=(($foo-1)*$param_pagelimit)+1}
<a href="{module_action_link module='News' action='default' urlonly=1 category='Articles' start=$goto pagelimit=$param_pagelimit}">
{$num}{assign var=num value=$num+1}
</a>
</li>
{/for}
<li class="arrow {if $num eq $pagecount} unavailable{/if}">
<a href="{module_action_link module='News' action='default' urlonly=1 category='Articles' start=$goto pagelimit=$param_pagelimit}">
»
</a>
</li>
</ul>
{assign var=num value=0}
{/capture}
{/if}
{if !empty($pagenumbering)}{$pagenumbering}{/if}
{foreach from=$items item=entry}
<article class="NewsSummary">
<h1 class="NewsSummaryLink">
<a href="{$entry->moreurl}" title="{$entry->title|cms_escape:htmlall}">{$entry->title|cms_escape}</a>
</h1>
{if $entry->postdate}
<p class="NewsSummaryPostdate">
<i class="general foundicon-calendar"></i> {$entry->postdate|cms_date_format}
</p>
{/if}
{if !empty($entry->authorname)}
<p class="NewsSummaryAuthor">
{$author_label} {$entry->authorname}
</p>
{/if}
{if $entry->summary}
{eval var=$entry->summary assign=temp}
<p class="NewsSummarySummary">
{$temp|strip_tags|truncate:100:''} {$entry->morelink}
</p>
{else if $entry->content}
{eval var=$entry->content assign=temp}
<p class="NewsSummaryContent">
{$temp|strip_tags|truncate:100:''} {$entry->morelink}
</p>
{/if}
</article>
{/foreach}
{if !empty($pagenumbering)}{$pagenumbering}{/if}
{/strip}
Also, to ensure the session var is cleared, I put
{if $page_alias ne 'articles'}{session_erase var='pagecount'}{/if}
in the template header.