News module problem - news detail page messes with CMS {content} placeholder

Have a question or a suggestion about a 3rd party addon module or plugin?
Let us know here.
Post Reply
codegrunt
Forum Members
Forum Members
Posts: 12
Joined: Mon Oct 11, 2010 9:24 pm

News module problem - news detail page messes with CMS {content} placeholder

Post by codegrunt »

Howdy.  I am using the News module and have come across some problematic behaviour which I am unsure how to fix. 

I am calling the news module via a CMS template where the relevant section looks like this:

Code: Select all

<div id="main_content">
	<h1>{content label="main heading" oneline="true" default=""}</h1> 
        {news category="$mySectionAlias"}
</div>

I have two custom news templates setup, one for the summary listing and one for the detail listing.

The summary listing page renders as expected when a page associated with the above CMS template is called:

Code: Select all

<h1>Announcements</h1> 
                                <!-- Displaying News Module -->
<!-- News Categories: 'example-category' -->
<!-- Start News Display Template -->

<ul id="file_listing">

<li><a href="http://127.0.0.1/example_site/news/7/73/Next-board-meeting-October-27th.html" title="Next board meeting October 27th">Next board meeting October 27th</a>
</li>
<li><a href="http://127.0.0.1/example_site/news/6/73/Send-the-office-your-best-photos.html" title="Send the office your best photos">Send the office your best photos and check out pictures of the 2010 Olympics here.</a>
</li>
</ul>
<!-- End News Display Template -->
The string "Announcements" is from the contents of the default content placeholder in the CMS template.

However the news detail template is messed up once rendered.  What is happening is that the news detail element appears to be getting stuffed into the content tag of the CMS template and then an unwanted summary listing is being inserted where the original "{news}" tag was located:

Code: Select all

<h1>  <h3 id="NewsPostDetailTitle">Next board meeting October 27th</h3>

<hr id="NewsPostDetailHorizRule" />

<div id="NewsPostDetailContent">
	Next board meeting October 27th
</div>

<div id="NewsPostDetailReturnLink"><a href="http://127.0.0.1/example_site/news-page.html">Return</a></div>
</h1>
                                 <!-- Displaying News Module -->
<!-- News Categories: 'example-category' -->
<!-- Start News Display Template -->

<ul id="file_listing">
<li><a href="http://127.0.0.1/example_site/news/7/73/Next-board-meeting-October-27th.html" title="Next board meeting October 27th">Next board meeting October 27th</a>
</li>

<li><a href="http://127.0.0.1/example_site/news/6/73/Send-the-office-your-best-photos.html" title="Send the office your best photos">Send the office your best photos and check out pictures of the 2010 Olympics here.</a>
</li>
</ul>
<!-- End News Display Template -->
I have taken an initial look at the code but am not immediately sure where this issue is occurring.  I am guessing that there is a recursive eval() happening somewhere where it should not be but so far have not been able to nail it down.

Any help on fixing this much appreciated.

Cheers
CODEgrunt Consulting - total geek trash, coder / troubleshooter for hire
User avatar
Dr.CSS
Moderator
Moderator
Posts: 12711
Joined: Thu Mar 09, 2006 5:32 am
Location: Arizona

Re: News module problem - news detail page messes with CMS {content} placeholder

Post by Dr.CSS »

The default behavior of news is to fill the {content} tag area, whether it is the same page it's in or the detailpage you send it to, you may want to make a new page and send the "click to detail" there, you may also be able to use the inline= parameter to keep it where it is...
codegrunt
Forum Members
Forum Members
Posts: 12
Joined: Mon Oct 11, 2010 9:24 pm

Re: News module problem - news detail page messes with CMS {content} placeholder

Post by codegrunt »

Thanks for the reply.

On the initial summary page, the {content} tag is left alone - it is only when accessed via the detail link that this issue occurs.  It still knows about the calling template so it is not like it does not have access to the template structure.  This behaviour also causes it to trigger the {news} placeholder a second time.  The inline="true" parameter makes no difference as far as I can tell (unless I am misunderstanding where you are suggesting placing it).

I have to admin that this behaviour seems counter-intuitive and more like a bug.

I took an initial peek at the module source but am not yet familiar enough with CMSMadeSimple's internals to be able track down where in the module it deals with the calling template.  Any pointers on where to start to try to correct this behaviour?  A grep for the string "content" in the source is not particularly helpful in this situation.

=)

As an aside, the calendar module does not seem to have the same issue and worked fine for me with the inline parameter.
   
Again, any help here appreciated.

Cheers
CODEgrunt Consulting - total geek trash, coder / troubleshooter for hire
User avatar
Dr.CSS
Moderator
Moderator
Posts: 12711
Joined: Thu Mar 09, 2006 5:32 am
Location: Arizona

Re: News module problem - news detail page messes with CMS {content} placeholder

Post by Dr.CSS »

Correct on the fact that the summary view stays where you put it as it just calls the news module to output what is in the summary template where it is, when you click the detail link is where it gets the idea or knows that it is supposed to display in the {content} part...

Sorry, I just read the News Help again and there is no inline parameter, you may want to tell it to go to a detailpage instead...
codegrunt
Forum Members
Forum Members
Posts: 12
Joined: Mon Oct 11, 2010 9:24 pm

Re: News module problem - news detail page messes with CMS {content} placeholder

Post by codegrunt »

Dr.CSS wrote: Correct on the fact that the summary view stays where you put it as it just calls the news module to output what is in the summary template where it is, when you click the detail link is where it gets the idea or knows that it is supposed to display in the {content} part...
Howdy.  After some digging it looks like "modules/News/action.detail.php" is responsible for the content on the detail page.  If I add an echo "hello world" to the top of that, it also appears within the {content} tag once parsed.  Looking at News.module.php I noticed the following line in the method "SearchResult":

Code: Select all

$result[2] = $this->CreateLink('cntnt01', 'detail', $returnid, '', array('articleid' => $articleid) ,'', true, false, '', true, $prettyurl);
Searching through the codebase suggests that "cntnt01" is the name of the default content placeholder associated with any given page (I believe this is confirmed by looking at the "cms_module_Redirect()" method in "lib/classes/module_support/modredirect.inc.php").  So unless I am wrong, the problem is that News hardcodes the variable it replaces or at least does not explicitly change the default.  If I add an "echo $id;" to the top of the "action.detail.php" script it does in fact spit out "cntnt01" as the current value.

Looking at CGCalender for reference is not helping that much unfortunately.

Spitting out the "$id" value on the summary page gives "ma2096" so I am having to gather $id is a generated value and not static (except for the default content block).

So I guess the next questions are:

1. how does one retrieve the name of the placeholder that the given news instance was originally called via (apparently passed via $id)?

2. where does the substitution for the original placeholder actually occur (it does not appear to happen in the News.module.php class file so I am assuming a parent method is being called somewhere.

Any help appreciated.

Cheers
CODEgrunt Consulting - total geek trash, coder / troubleshooter for hire
User avatar
Dr.CSS
Moderator
Moderator
Posts: 12711
Joined: Thu Mar 09, 2006 5:32 am
Location: Arizona

Re: News module problem - news detail page messes with CMS {content} placeholder

Post by Dr.CSS »

Now you are getting past my realm of abilities, hope one of the more programming types comes to help...
Post Reply

Return to “Modules/Add-Ons”