News module pretty urls

The place to talk about things that are related to CMS Made simple, but don't fit anywhere else.
Post Reply
zimmo
Forum Members
Forum Members
Posts: 27
Joined: Fri Sep 28, 2012 9:00 am

News module pretty urls

Post 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
User avatar
Dr.CSS
Moderator
Moderator
Posts: 12709
Joined: Thu Mar 09, 2006 5:32 am
Location: Arizona

Re: News module pretty urls

Post 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
Wishbone
Power Poster
Power Poster
Posts: 1369
Joined: Tue Dec 23, 2008 8:39 pm

Re: News module pretty urls

Post by Wishbone »

Not for next and prev links ;) CG says 'not gonna happen'
User avatar
Gregor
Power Poster
Power Poster
Posts: 1874
Joined: Thu Mar 23, 2006 9:25 am
Location: The Netherlands

Re: News module pretty urls

Post by Gregor »

[Off topic]Would you mind explaining how you made the archive on the frontpage. Looks very nice![/Off topic]
Wishbone
Power Poster
Power Poster
Posts: 1369
Joined: Tue Dec 23, 2008 8:39 pm

Re: News module pretty urls

Post by Wishbone »

He's loading all the posts at once, and using a jQuery slider to show them. Very nice!
User avatar
Gregor
Power Poster
Power Poster
Posts: 1874
Joined: Thu Mar 23, 2006 9:25 am
Location: The Netherlands

Re: News module pretty urls

Post by Gregor »

Higher cmsms magic ;)
User avatar
manuel
Power Poster
Power Poster
Posts: 353
Joined: Fri Nov 30, 2007 9:15 am

Re: News module pretty urls

Post 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 ;D

Greetings,
Manuel
Do you like your open source cms? Buy from the CMSMS partners || Donate
User avatar
Dr.CSS
Moderator
Moderator
Posts: 12709
Joined: Thu Mar 09, 2006 5:32 am
Location: Arizona

Re: News module pretty urls

Post 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/
User avatar
Gregor
Power Poster
Power Poster
Posts: 1874
Joined: Thu Mar 23, 2006 9:25 am
Location: The Netherlands

Re: News module pretty urls

Post 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.
psy
Power Poster
Power Poster
Posts: 463
Joined: Sat Jan 22, 2005 11:19 am

Re: News module pretty urls

Post 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}">
					&laquo;
				</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}">
					&raquo;
				</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.
Post Reply

Return to “The Lounge”