Page 1 of 1

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

Posted: Tue Sep 28, 2010 1:41 pm
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.

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

Posted: Tue Sep 28, 2010 3:47 pm
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.

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

Posted: Wed Oct 13, 2010 4:23 pm
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?

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

Posted: Thu Oct 14, 2010 1:22 pm
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.

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

Posted: Fri Jan 07, 2011 6:49 pm
by jeroen914
I see you solved this, but how?
Tried several things but haven't figured it out so far...

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

Posted: Tue Jun 28, 2011 11:56 am
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 ;)