how to link to a news item using self link

General project discussion. NOT for help questions.
Post Reply
Zack
Forum Members
Forum Members
Posts: 24
Joined: Fri Nov 16, 2007 2:31 pm

how to link to a news item using self link

Post by Zack »

I searched the forum but couldn't find anything on this topic. Maybe I missing something very simple. this is what I wan to achieve:

I'm writing a blurb on my home page which links to a news item. This blurb is independent of the news module. Please help.
MantaPro
Forum Members
Forum Members
Posts: 97
Joined: Sun Feb 03, 2008 8:14 pm

Re: how to link to a news item using self link

Post by MantaPro »

Just been searching the forum trying to find the same solution, but I was pretty sure that it was fuzzy thinking - i.e. I was trying to go about it the wrong way.

Came up with 2 ideas. The 'purest' solution is that a summary of a news item is basically just a link plus what ever additional content and formatting that the summary template adds. So to have a link in some content of a page, go about it like this.

1. Ensure that new article is assigned to a category that unique identifies it. i.e. the category has one and only one article, the one you want to link to (remember you can set up this category as a child of its original category and that any other new displays you use can have category="category*" where the * tells the news module to include child categories
2. Create a new news summary template,  copy/paste + edit it to be just the absolute minimum, probably just need 3 lines of code :

Code: Select all

{foreach from=$items item=entry}
   {$entry->titlelink}
{/foreach}
3. Then in your page content, insert the code

Code: Select all

{news summarytemplate='yourtemplate' category="yourcategory"} 
Now you have a news summary title link embedded in your page content, where the summary template used for the link is stripped out to just a link. You can of course add detail page and detail template parameters as usual.

A second less 'pure' solution but it enables a bit more control is to make use of the {global_content name='myblob'} tag, this way you have a page that you link to AND a news item, but you use a global content block so that there is actually only one instance of the actual content. i.e.
1. Edit your news item, cut to your clip board all of the words and images in the news items 'Content' section
2. Create a new global content block, paste into the blocks content section the code from your clipboard, from 1. above
3. In the 'Content' section of the NEWS item add the code {global_content name='myblob'} to use the newly created global content block created in 2. above
This gets you a news item as per the original, but you now have the main content of it in a global content block ready to reuse
4. Create a new page, set it to active but not displayed in the menus, in the content add the same global content tag as in 3. above
5. In the page you want to link from, just add a {cms_selflink page="page_created_in_4_above" etc}
The downside of this is it is more complicated and less intuitive where content is when you come to edit it, but the advantage is that you have manual control over the text displayed in the link (rather than the first method where the link text is the news item title 
 
Hope this helps
Post Reply

Return to “General Discussion”