[SOLVED] News module: show title of category at top of summary template?

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
beherenow_uk
Forum Members
Forum Members
Posts: 103
Joined: Fri Nov 28, 2008 11:26 am

[SOLVED] News module: show title of category at top of summary template?

Post by beherenow_uk »

Hi all,

I have searched and searched for this to no avail, i hope someone can help me...

Using the News module 2.10.6 on CMSMS 1.8.1, I have a "browse category" page set up.
My page is here: http://www.care-plan-management-system.co.uk/our-news-sandbox/

When you click on say 'human resources' I want it to say 'Human Resources' at the top of the page and then list all of the articles relating to that category. At the moment I cannot fond a way to display the category name at the top of the page as an . Please help!

My summary template code is:

Code: Select all

{if $itemcount > 0}

<!-- Start News Display Template -->
{foreach from=$items item=entry}
<div class="NewsArchiveSummarywrap">

<div class="NewsSummaryLink">
<a href="{$entry->moreurl}" title="{$entry->title|cms_escape:htmlall}">{$entry->title|cms_escape}</a>
</div>

{if $entry->postdate}
	<span class="newsdate">	{$entry->postdate|cms_date_format}</span>
{/if}


{if $entry->summary}
	<div class="NewsArchiveSummary">
		<p>{eval var=$entry->summary|truncate:200}</p>
	</div>

	<div class="NewsArchiveMorelink">
		<p><span class="bold"><a href="{$entry->moreurl}"{$entry->moreurl}">Read more</span></a></p>
	</div>

{else if $entry->content}

	<div class="NewsSummaryContent">
		{eval var=$entry->content|truncate:50}
	</div>
{/if}

{if isset($entry->extra)}
    <div class="NewsSummaryExtra">
        {eval var=$entry->extra}
	{* {cms_module module='Uploads' mode='simpleurl' upload_id=$entry->extravalue} *}
    </div>
{/if}

{* this is for showing the Source of each Article - if needed, but not on this page atm - karl *}
{* {if isset($entry->fields)}
  {foreach from=$entry->fields item='field'}
     <div class="NewsSummaryField">
        {if $field->type == 'file'}
          <img src="{$entry->file_location}/{$field->value}"/>
        {else}
          {$field->name}: {eval var=$field->value}
        {/if}
     </div>
  {/foreach}
{/if} *}

</div>
{/foreach}

{if $pagecount > 1}
  <p>
{if $pagenumber > 1}
{$firstpage} {$prevpage} 
{/if}
{$pagetext} {$pagenumber} {$oftext} {$pagecount}
{if $pagenumber < $pagecount}
 {$nextpage} {$lastpage}
{/if}
</p>
{/if}

{else}

<h3>Sorry, there is no news to report at the moment.</h3>
{/if}


<!-- End News Display Template -->

But i would expect it to be something like:

Code: Select all


{if $itemcount > 0}

{*CODE FOR CATEGORY TITLE HERE???*}

<!-- Start News Display Template -->
{foreach from=$items item=entry}
<div class="NewsArchiveSummarywrap">

<div class="NewsSummaryLink">
<a href="{$entry->moreurl}" title="{$entry->title|cms_escape:htmlall}">{$entry->title|cms_escape}</a>
</div>

{if $entry->postdate}
	<span class="newsdate">	{$entry->postdate|cms_date_format}</span>
{/if}


{if $entry->summary}
	<div class="NewsArchiveSummary">
		<p>{eval var=$entry->summary|truncate:200}</p>
	</div>

	<div class="NewsArchiveMorelink">
		<p><span class="bold"><a href="{$entry->moreurl}"{$entry->moreurl}">Read more</span></a></p>
	</div>

{else if $entry->content}

	<div class="NewsSummaryContent">
		{eval var=$entry->content|truncate:50}
	</div>
{/if}

{if isset($entry->extra)}
    <div class="NewsSummaryExtra">
        {eval var=$entry->extra}
	{* {cms_module module='Uploads' mode='simpleurl' upload_id=$entry->extravalue} *}
    </div>
{/if}

{* this is for showing the Source of each Article - if needed, but not on this page atm - karl *}
{* {if isset($entry->fields)}
  {foreach from=$entry->fields item='field'}
     <div class="NewsSummaryField">
        {if $field->type == 'file'}
          <img src="{$entry->file_location}/{$field->value}"/>
        {else}
          {$field->name}: {eval var=$field->value}
        {/if}
     </div>
  {/foreach}
{/if} *}

</div>
{/foreach}

{if $pagecount > 1}
  <p>
{if $pagenumber > 1}
{$firstpage} {$prevpage} 
{/if}
{$pagetext} {$pagenumber} {$oftext} {$pagecount}
{if $pagenumber < $pagecount}
 {$nextpage} {$lastpage}
{/if}
</p>
{/if}

{else}

<h3>Sorry, there is no news to report at the moment.</h3>
{/if}


<!-- End News Display Template -->
So that it only displays the category title once at the top. Any ideas? I hope someone can help, it's driving me crazy!

Thanks in advance!

Karl.
Last edited by beherenow_uk on Tue Sep 28, 2010 3:48 pm, edited 1 time in total.
beherenow_uk
Forum Members
Forum Members
Posts: 103
Joined: Fri Nov 28, 2008 11:26 am

Re: News module: show title of category at top of summary template?

Post by beherenow_uk »

I can't believe it, it took me all day but i found the solution and im a little annoyed at how simple it was. I was probably digging too deep:

I put {get_template_vars} into my template to show the $variable i needed. And it was category_name.

So i simply put {$category_name} to the top of my template, and joy oh joy it works.

Thanks Google.
mrchristoph
Forum Members
Forum Members
Posts: 20
Joined: Sat May 15, 2010 9:54 am

Re: [SOLVED] News module: show title of category at top of summary template?

Post by mrchristoph »

Hmm this doesnt seem to work for me, I only have a "param_category_id" rather than a name when I get the variables. Any idea how I have convert this to the category name?
beherenow_uk
Forum Members
Forum Members
Posts: 103
Joined: Fri Nov 28, 2008 11:26 am

Re: [SOLVED] News module: show title of category at top of summary template?

Post by beherenow_uk »

Hi,

Which template are you inserting your {get_template_vars} into? Also, what CMSMS version, news module version are u using? The older versions work differently to the newer ones.

Here's a guess at an answer... When i say 'template' i mean the News template, not the general CMSMS page template...You get different Vars depending on what template you put {get_template_vars} into.

This is also good for finding out the vars for other modules too, like ForumMS for example.

Hope this helps.

Karl.
Last edited by beherenow_uk on Thu Oct 14, 2010 1:25 pm, edited 1 time in total.
jeroen914
Forum Members
Forum Members
Posts: 12
Joined: Sun Oct 25, 2009 11:06 pm

Re: [SOLVED] News module: show title of category at top of s

Post by jeroen914 »

I see you solved this, but how?
Tried several things but haven't figured it out so far...
tpsvca
Forum Members
Forum Members
Posts: 14
Joined: Mon Feb 08, 2010 8:22 am

Re: [SOLVED] News module: show title of category at top of s

Post by tpsvca »

My solution:

first you must to do everything about post title instead {title}:
http://forum.cmsmadesimple.org/viewtopic.php?t=30475
or
http://www.dootch.com/2010/04/seo-frien ... -in-cmsms/
(content stealer? :D )

After that:
put in to your summary template following code:

Code: Select all

{foreach from=$entry->categories item='category' name=cat}
	{if $category.category_id == $param_category_id}
		{assign var='pagetitle' value=$category.name}
	{/if}
{/foreach}
Works with News, CGBlog and Products ;)
Post Reply

Return to “CMSMS Core”