How to link to different detailpages in {news}

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.
Jacob B

How to link to different detailpages in {news}

Post by Jacob B »

Hello all,
I use CMSMS 1.1.2 and News module 2.3.0.2.

I want to show 8 summarized newsitems at the homepage and from there link to different detailpages. Let's say I have two categories: 1 and 2. At the homepage the summarized items of the two categories can be shown in a mixed way. But when clicked on an item, it needs to be shown in the corresponding detailpage (In my example 1news or 2news). I tried to use a comma like this:

Code: Select all

{news number='8' category="1" detailpage="1news", category="2" detailpage="2news" }
but it results in that only the '2' items are properly shown on the homepage (including the link to the corresponding detailpage), while the '1' items are missing.
Anybody a tip how to handle this? Thanks for thinking about my question!
Cheers,
Jacob
alby

Re: How to link to different detailpages in {news}

Post by alby »

Jacob B wrote: I want to show 8 summarized newsitems at the homepage and from there link to different detailpages. Let's say I have two categories: 1 and 2. At the homepage the summarized items of the two categories can be shown in a mixed way. But when clicked on an item, it needs to be shown in the corresponding detailpage (In my example 1news or 2news). I tried to use a comma like this:

Code: Select all

{news number='8' category="1" detailpage="1news", category="2" detailpage="2news" }
but it results in that only the '2' items are properly shown on the homepage (including the link to the corresponding detailpage), while the '1' items are missing.
Anybody a tip how to handle this? Thanks for thinking about my question!
Use one detail template.
In this template:

Code: Select all

{if $entry->category eq 1}
  Here there is template part for category 1
{elseif $entry->category eq 2}
  Here there is template part for category 2
{else}
  Acc... Wrong!
{/if}
Alby
Jacob B

Re: How to link to different detailpages in {news}

Post by Jacob B »

Thanks,
I think I understand you. But on thing I don't understand: How do I change

Code: Select all

Here there is template part for category 1
from your example to the a valid specification of the detailpage. To be honest I do not yet fully understand what the $ and $entry statements mean, so up to now my trial and error strategy didn't result in a right statement... Hope you can make this last thing clear for me.
Regards from the Netherlands
Last edited by Jacob B on Thu Oct 04, 2007 11:24 am, edited 1 time in total.
alby

Re: How to link to different detailpages in {news}

Post by alby »

Jacob B wrote: I think I understand you. But on thing I don't understand: How do I change

Code: Select all

Here there is template part for category 1
from your example to the a valid specification of the detailpage.
Template is html code with tag (code or variable)

In

Code: Select all

Here there is template part for category 1
add your html code, in this case for category 1 only.

Look for default template detail and substitute.
For example:

Code: Select all

{if $entry->category eq 1}

	<div id="NewsPostDetailCategory">{$category_label} {$entry->category} (CATEGORY 1)</div>
  {if $entry->formatpostdate}
	<div id="NewsPostDetailDate">{$entry->formatpostdate}</div>
  {/if}
	<h3 id="NewsPostDetailTitle">{$entry->title}</h3>

	<hr id="NewsPostDetailHorizRule" />

  {if $entry->summary}
	<div id="NewsPostDetailSummary"><strong>{eval var=$entry->summary}</strong></div>
  {/if}

	<div id="NewsPostDetailContent">{eval var=$entry->content}</div>

	<div id="NewsPostDetailPrintLink">{$entry->printlink}</div>
  {if $return_url != ""}
	<div id="NewsPostDetailReturnLink">{$return_url}</div>
  {/if}

{elseif $entry->category eq 2}

	<div id="NewsPostDetailCategory">{$category_label} {$entry->category} (CATEGORY 2)</div>
  {if $entry->formatpostdate}
	<div id="NewsPostDetailDate">{$entry->formatpostdate}</div>
  {/if}
	<h3 id="NewsPostDetailTitle">{$entry->title}</h3>

	<hr id="NewsPostDetailHorizRule" />

  {if $entry->summary}
	<div id="NewsPostDetailSummary"><strong>{eval var=$entry->summary}</strong></div>
  {/if}

	<div id="NewsPostDetailContent">{eval var=$entry->content}</div>

	<div id="NewsPostDetailPrintLink">{$entry->printlink}</div>
  {if $return_url != ""}
	<div id="NewsPostDetailReturnLink">{$return_url}</div>
  {/if}

{else}
  Acc... Wrong!

{/if}

Alby
Jacob B

Re: How to link to different detailpages in {news}

Post by Jacob B »

Thanks again Alby
Hmmm, this thread is getting longer than I expected, I'm sorry, but I think we're almost there. The thing is, that you mis-interpreted a small thing in my question. I do understand how to change the News template.
However, with detailpage I mean the physical location where the detailpage is shown after you click on the summarized item. I want to point to a page alias, in case of category 1 to "page 1" and in case of category 2 to "page 2´, but I don't know the proper way to add this to the template.

My summary template looks like this, the unclearity is at the end of the template:

Code: Select all

<!-- Start News Display Template -->

<div class="titel">Nieuwe berichten</div>


{foreach from=$items item=entry}
<div class="NewsSummary">

{if $entry->formatpostdate}
	<div class="NewsSummaryPostdate">
		{$entry->postdate|date_format:"%d %b. '%y"} |&nbsp
	</div>
{/if}

<div class="NewsSummaryCategory">
	{$entry->category}
</div>

<div class="NewsSummaryLink">
	{$entry->titlelink}
</div>

{if $entry->category eq "1"}
  detailpage.......page 1  <!-- What exactly do I type here? -->
{elseif $entry->category eq "2"}
  detailpage.......page 2 <!-- and here? -->
{/if}

{else}
  Acc... Wrong!

</div>
{/foreach}
<!-- End News Display Template -->
alby

Re: How to link to different detailpages in {news}

Post by alby »

Jacob B wrote: The thing is, that you mis-interpreted a small thing in my question. I do understand how to change the News template.
Yes, I mis-interpreted, I think that you want 2 detail page for different layout template
If you want 2 different page only (I don't know why) is possible if you hack news php code or hack template code/alias page:

1. Call news module:
{news ....... detailpage="news-detail"}

2. Add 2 page with alias:
news-detail-1
news-detail-2

3. In Summary template add this code:
........

{$entry->titlelink|replace:"news-detail":"news-detail-`$entry->category`"}

........
EDIT: add backtick

This is UNTESTED ::)


Alby
Last edited by alby on Fri Oct 05, 2007 8:06 pm, edited 1 time in total.
User avatar
Dr.CSS
Moderator
Moderator
Posts: 12711
Joined: Thu Mar 09, 2006 5:32 am

Re: How to link to different detailpages in {news}

Post by Dr.CSS »

You could try...

{news number='4' category="1" detailpage="1news"}
{news number='4' category="2" detailpage="2news" }
Jacob B

Re: How to link to different detailpages in {news}

Post by Jacob B »

Alby, I tried your suggestion, which is quite creative I think, but unfortunately both categories opened the news details at the home-page, instead of the categorie-pages. It is possible that is has to do with pretty-url settings?

Mark's idea is also something I already tried, and maybe the best at the moment. However newsitems in this case are not sorted by date, is there a function to overrule the sorting of the two separate categories and sort the whole list?

I appreciate all your help. I really like everybody is doing these things for free. And off course I'll spread the news about this wonderful CMS. Keep up the good work all programmers!
Jacob
alby

Re: How to link to different detailpages in {news}

Post by alby »

Jacob B wrote: Alby, I tried your suggestion, which is quite creative I think, but unfortunately both categories opened the news details at the home-page, instead of the categorie-pages. It is possible that is has to do with pretty-url settings?
Have you 2 pages with news-detail-1 and news-detail-2 (if 1 and 2 are your categories)?
Check in html source if title link is correct or not.
I forgot backtick in example!

Alby
Last edited by alby on Fri Oct 05, 2007 8:08 pm, edited 1 time in total.
Jacob B

Re: How to link to different detailpages in {news}

Post by Jacob B »

alby wrote:
Have you 2 pages with news-detail-1 and news-detail-2 (if 1 and 2 are your categories)?
Check in html source if title link is correct or not.
I forgot backtick in example!

Alby
Yes
When I check html source of the titlelink, the detailpage is not in the URL, in my case it looks like this:
http://www.domain.org/news/4/55.html
So i doubt whether your replace function can work in this way. Do you think it can really work like this? Is the detailpage normally included in the URL?

I'm still thinking of Mark's idea:
mark wrote: You could try...

{news number='4' category="1" detailpage="1news"}
{news number='4' category="2" detailpage="2news" }
but the big disadvantage here is the sorting of the items, because they're now sorted by category+date and not by date only. Or is there a solution for this as well?

If Alby's suggestion can be solved I rather prefer that one.
Thanks
Jacob
alby

Re: How to link to different detailpages in {news}

Post by alby »

Jacob B wrote:
alby wrote:
Have you 2 pages with news-detail-1 and news-detail-2 (if 1 and 2 are your categories)?
Check in html source if title link is correct or not.
I forgot backtick in example!
Yes
When I check html source of the titlelink, the detailpage is not in the URL, in my case it looks like this:
http://www.domain.org/news/4/55.html
So i doubt whether your replace function can work in this way. Do you think it can really work like this? Is the detailpage normally included in the URL?
I don't remember for prettyurl id  :-[

Unset (in config.php) prettyurl (for debug only).
Your link will be:  index.php?mact=News,cntnt01,detail,0&cntnt01articleid=1&cntnt01returnid=21

21 is the detail page-ID
check is different for ID news-detail-1 and ID news-detail-2  AND if exact

Alby
Jacob B

Re: How to link to different detailpages in {news}

Post by Jacob B »

Both categories show the same page-ID. For test purposes I named one of my pages "news-detail" and this is where both categories show the details of the new-sitem. I still hope you (or someone else) can fix this issue.
Jacob
alby

Re: How to link to different detailpages in {news}

Post by alby »

Jacob B wrote: Both categories show the same page-ID. For test purposes I named one of my pages "news-detail" and this is where both categories show the details of the new-sitem. I still hope you (or someone else) can fix this issue.
I tested this and don't work  :-X
I remember a wrong case and the answer is in my post:
alby wrote: Your link will be:  index.php?mact=News,cntnt01,detail,0&cntnt01articleid=1&cntnt01returnid=21
There is ID and not alias page
It's not possible in this way. You must hack php code for this

Sorry,
Alby
Jacob B

Re: How to link to different detailpages in {news}

Post by Jacob B »

Thanks for helping and thinking Alby. I really appreciate you spend so much time on helping other people.
But can somebody answer this question? Thanks.
Jacob B wrote:
I'm still thinking of Mark's idea:
mark wrote: You could try...

{news number='4' category="1" detailpage="1news"}
{news number='4' category="2" detailpage="2news" }
but the big disadvantage here is the sorting of the items, because they're now sorted by category+date and not by date only. Or is there a solution for this as well?
User avatar
Dr.CSS
Moderator
Moderator
Posts: 12711
Joined: Thu Mar 09, 2006 5:32 am

Re: How to link to different detailpages in {news}

Post by Dr.CSS »

From the news help page...

(optional) sortby="news_date" - Field to sort by. Options are: "news_date", "summary", "news_data", "news_category", "news_title". Defaults to "news_date".
Locked

Return to “CMSMS Core”