News links to external URLs?

For questions and problems with the CMS core. This board is NOT for any 3rd party modules, addons, PHP scripts or anything NOT distributed with the CMS made simple package itself.
Locked
bawbgale

News links to external URLs?

Post by bawbgale »

I would like to use the News module for both news articles on my own site and links to news on other sites? I've checked out the Bookmarks module, but that doesn't quite do what I want because I want to intermix local and external articles within the same categories, and sort them by date. Does anyone know of a way to do that? Is there a way to put some conditional code in the summary template so that if the content of the article begins with "http" it uses that URL for the title link instead of linking to my local page?
Ted
Power Poster
Power Poster
Posts: 3329
Joined: Fri Jun 11, 2004 6:58 pm

Re: News links to external URLs?

Post by Ted »

You can do a lot of things with the summary template, including conditional code.  It's a full smarty template and allows for all kinds of good logic stuff.
bawbgale

Re: News links to external URLs?

Post by bawbgale »

Thanks, wishy. I'm new to smarty. I quickly found the {if} syntax, but can't find any "left" function -- i.e. if the left 4 characters = "http".... Can you tell me (or point me to where I might learn) how to do that?
Ted
Power Poster
Power Poster
Posts: 3329
Joined: Fri Jun 11, 2004 6:58 pm

Re: News links to external URLs?

Post by Ted »

Try {if $summary|truncate:4 == 'http'}
bawbgale

Re: News links to external URLs?

Post by bawbgale »

I got it to work! Here's the final code:

{if $entry->content|truncate:4:"" == 'http'}
content}">{$entry->title}
{else}
{$entry->titlelink}
{/if}

I'm putting the URL in content instead of summary, because I still want to include summary text about the article even if the article itself is offsite.

Thanks a bunch!

- Bob
Locked

Return to “CMSMS Core”