[solved] - Newsmodule: How to show default newsitem?

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.
Post Reply
jvdoorn
New Member
New Member
Posts: 8
Joined: Thu Oct 02, 2008 3:27 pm

[solved] - Newsmodule: How to show default newsitem?

Post by jvdoorn »

Using cms ms 1.5.1

I have created a newspage with a leftmenu and a content-area. The leftmenu is a list with news titels (with a summery-template). Clicking a title will show the content of the article in the content area (with a detail-template).

Can i show the content of the last newsitem in the contentarea, if no title is clicked? So the last newsitem is shown by default?
Using {news detailtemplate='mydetailtemplate'} it now shows a summery list in the content area.


Regards.
Last edited by jvdoorn on Thu Feb 26, 2009 2:35 pm, edited 1 time in total.
markS
Forum Members
Forum Members
Posts: 58
Joined: Wed Aug 20, 2008 3:04 pm

Re: Newsmodule: How to show default newsitem

Post by markS »

Hello,

This is exactly the issue I've been having with the news module.  What would be great is if we could have an additional action defined so that we are able to have the detail view when we want it, like:

{news detailpage="news" detailtemplate="detail" number="1" action="detail"}

Unfortunately action="detail" doesn't exist so we might have to make a feature request for that, I suppose? ( EDIT:  I have made a feature request in the cmsms forge for the news module.)

I have discovered a workaround though, on my menu item for the news page I have replaced the usual cms_selflink with a call to the news module, so that the link it generates will lead me directly to the detail view, like:

{news detailpage="news" detailtemplate="detail" summarytemplate="linkonly" moretext="News" number="1"}

the summary template 'linkonly' in this case is exactly what it says:


{foreach from=$items item=entry}
{$entry->morelink}
{/foreach}


In the case of my website the news link isn't being generated by the menu_manager, so I can easily drop this in.  It would require a little more work in the case of a menu being generated by menu manager, but it shouldn't be too tricky to add in an exception, like:

{if $node->alias == "news"}
{news detailpage="news" detailtemplate="detail" summarytemplate="linkonly" moretext="News" number="1"}
{else}

{/if}

Or similar.

Hope this helps.

Mark.
Last edited by markS on Thu Feb 12, 2009 1:45 pm, edited 1 time in total.
jvdoorn
New Member
New Member
Posts: 8
Joined: Thu Oct 02, 2008 3:27 pm

Re: Newsmodule: How to show default newsitem

Post by jvdoorn »

Thanks a lot for this workaround! I indeed needed a "news" link generated by the menu manager, and now it's working like i want. A action=detail link would be a nice addition for the next version of the News module.
RonnyK
Support Guru
Support Guru
Posts: 4962
Joined: Wed Oct 25, 2006 8:29 pm

Re: [solved] - Newsmodule: How to show default newsitem?

Post by RonnyK »

In the upcoming 1.5.3 there will be a parameter for this.
(optional) articleid="" - This parameter is only applicable to the detail view. It allows specifying which news article to display in detail mode. If the special value -1 is used, the system will display the newest, published, non expired article.
Ronny
thestorm
New Member
New Member
Posts: 4
Joined: Thu Aug 14, 2008 11:36 am

Re: [solved] - Newsmodule: How to show default newsitem?

Post by thestorm »

Hi there,

I am trying to achieve the same as jvdoorn but am new to PHP and having trouble editing my Menu Manager template. I have Navigation that is two levels deep:

Home
News
Item3
  - Sub1
  - Sub2
Item4

And I want 'News' to link in the same way it does when outside of Menu Manager, i.e. as it does when using this workaround:
{news detailpage="news" detailtemplate="detail" summarytemplate="linkonly" moretext="News" number="1"}
The News module's set up for Mark's 'linkonly' workaround and works fine outside of Menu Manager... But I need it to link from the Menu and being rubbish at PHP (I'm learning!) I can't find where to put the following code in my Menu template.

CODE I WANT TO PLACE:
{if $node->alias == "news"}
{news detailpage="news" detailtemplate="detail" summarytemplate="linkonly" moretext="News" number="1"}
{else}

{/if}
MENU MANAGER TEMPLATE I WANT TO PLACE IT IN:

Code: Select all

{* CSS classes used in this template:
.activeparent - The top level parent when a child is the active/current page
li.active0n h3 - n is the depth/level of the node. To style the active page for each level separately. The active page is not clickable.
.clearfix - Used for the unclickable h3 to use the entire width of the li, just like the anchors. See the Tools stylesheet in the default CMSMS installation.
li.sectionheader h3 - To style section header
li.separator - To style the ruler for the separator *} 

{if $count > 0}
<ul>
{foreach from=$nodelist item=node}
{if $node->depth > $node->prevdepth}
{repeat string="<ul>" times=$node->depth-$node->prevdepth}
{elseif $node->depth < $node->prevdepth}
{repeat string="</li></ul>" times=$node->prevdepth-$node->depth}
</li>
{elseif $node->index > 0}</li>
{/if}

{if $node->current == true}
<li class="currentpage"><h3><dfn>Current page is {$node->hierarchy}: </dfn>{$node->menutext}</h3>

{elseif $node->parent == true}
<li class="activeparent"><a class="activeparent" href="{$node->url}"{if $node->accesskey != ''} accesskey="{$node->accesskey}"{/if}{if $node->tabindex != ''} tabindex="{$node->tabindex}"{/if}{if $node->titleattribute != ''} title="{$node->titleattribute}"{/if}><dfn>{$node->hierarchy}: </dfn>{$node->menutext}</a>

{elseif $node->type == 'sectionheader'}
<li class="sectionheader">{$node->menutext}

{elseif $node->type == 'separator'}
<li class="separator" style="list-style-type: none;"> <hr />

{else}
<li><a href="{$node->url}"{if $node->accesskey != ''} accesskey="{$node->accesskey}"{/if}{if $node->tabindex != ''} tabindex="{$node->tabindex}"{/if}{if $node->titleattribute != ''} title="{$node->titleattribute}"{/if}{if $node->target != ''} target="{$node->target}"{/if}><dfn>{$node->hierarchy}: </dfn>{$node->menutext}</a>

{/if}

{/foreach}
{repeat string="</li></ul>" times=$node->depth-1}</li>
</ul>
{/if}


There's probably a simple solution but I'm a complete beginner and could do with some help!  :)

Huge thanks in advance to anyone who can solve this!

Katie.
Post Reply

Return to “CMSMS Core”