Page 1 of 1

News Links from Browsecat

Posted: Thu Feb 21, 2008 8:18 pm
by Nullig
I have a problem with the News module and links from the browsecat page to subcategories.

My news categories are like this:

  Category - Family
    Subcategory - Birthdays
    Subcategory - Anniversaries
  Category - Friends
    Subcategory - Birthdays
    Subcategory - Anniversaries

My browse category template is:

Code: Select all

{if $count > 0}
  <ul id="List1">
  {foreach from=$cats item=node}
    {if $node.depth > $node.prevdepth}
      {repeat string="<ul class='List2'>" 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}
    <li class="newscategory">
    {if $node.count > 0}
      <a href="{$node.url}"><strong>{$node.news_category_name}</strong></a> ({$node.count})
    {else}
      <span><strong>{$node.news_category_name}</strong></span>
    {/if}
    {/foreach}
  {repeat string="</li></ul>" times=$node.depth-1}</li>
  </ul>
{/if}
I call it like this:

Code: Select all

<div id="NewsLeft1">
<p>
{news category='Family*' browsecat='1' browsecattemplate='default' summarytemplate='default' detailtemplate='default' detailpage='news-detail'}
</p>
</div>
<div id="NewsRight1">
<p>
{news category='Friends*' browsecat='1' browsecattemplate='default' summarytemplate='default' detailtemplate='default' detailpage='news-detail'}
</p>
</div>
The Browse Category page shows 2 listings, side-by-side, of the number of articles in each subcategory. When I click on the "Birthdays" link under "Family", the Summary page shows the Birthdays from both "Family" and "Friends". The link that is generated is:

Code: Select all

http://www.mysite.com/index.php?mact=News,cntnt01,default,0&cntnt01category=Birthdays&cntnt01browsecattemplate=default&cntnt01summarytemplate=default&cntnt01detailtemplate=default&cntnt01detailpage=20&cntnt01returnid=20
It doesn't seem to differentiate between the main categories. It looks to me that the category in the link should be "Family | Birthdays", not just "Birthdays".

CMS version 1.2.3
News version 2.6.1

Nullig

UPDATE

If I manually change category parameter of the link in my address bar to category=Family%20|%20Birthdays it works.
How can I get browsecat to create the proper link?

Re: News Links from Browsecat

Posted: Fri Feb 22, 2008 11:42 pm
by Nullig
OK, I found that if I changed these lines in action.browsecat.php from:

Code: Select all

	$parms['category'] = $row['news_category_name'];

	$row['url'] = $this->CreateLink($id,'default',$params['detailpage']!= ''?$params['detailpage']:$returnid,$row['news_category_name'],$parms,'',true);
to:

Code: Select all

	$parms['category'] = $row['long_name'];

	$row['url'] = $this->CreateLink($id,'default',$params['detailpage']!= ''?$params['detailpage']:$returnid,$row['long_name'],$parms,'',true);
it worked, but I'm not sure if it breaks something else...

Nullig

Re: News Links from Browsecat

Posted: Fri Feb 19, 2010 5:58 pm
by Mich-adg
Thanks, i had the same problem on a fresh 1.6.6 and News 2.10.3, and it solved it ! The dev team should take a look at this problem in the next upgrade.

Re: News Links from Browsecat

Posted: Wed May 12, 2010 1:25 pm
by hey
Hello, I'm french and I don't speak very well english.
So if I understand, Browsecat give the same think for all category.

I work with cmsms 1.6.6
I make that: in modules/news/action.default.php  I comment (with '/*' and '*/') line 67 to line 95. Now summary select news with 'news_category_id' in $params and not with 'category'.

Code: Select all

/*if (isset($params["category"]) && $params["category"] != '')
  {
    $category = cms_html_entity_decode(trim($params['category']));
    $categories = explode(',', $category);
    $query1 .= " (";
    $query2 .= " (";
    $count = 0;
    foreach ($categories as $onecat)
      {
	if ($count > 0)
	  {
	    $query1 .= ' OR ';
	    $query2 .= ' OR ';
	  }
	if (strpos($onecat, '|') !== FALSE || strpos($onecat, '*') !== FALSE)
	  {
	    $query1 .= "upper(mnc.long_name) like upper('" . trim(str_replace('*', '%', str_replace("'",'_',$onecat))) . "')";
	    $query2 .= "upper(mnc.long_name) like upper('" . trim(str_replace('*', '%', str_replace("'",'_',$onecat))) . "')";
	  }
	else
	  {
	    $query1 .= "mnc.news_category_name = '" . trim(str_replace("'",'_',$onecat)) . "'";
	    $query2 .= "mnc.news_category_name = '" . trim(str_replace("'",'_',$onecat)) . "'";
	  }
	$count++;
      }
    $query1 .= ") AND ";
    $query2 .= ") AND ";
  }
else*/ if( isset($params['category_id']) )
  {
    $query1 .= " ( mnc.news_category_id = '".$params['category_id']."' ) AND ";
    $query2 .= " ( mnc.news_category_id = '".$params['category_id']."' ) AND ";
  }
Thanks for try to decode me  :D.
If you think it's wrong, tell it to me.

Re: News Links from Browsecat

Posted: Wed May 12, 2010 3:07 pm
by hey
Ok I make a mistake.

it juste need to reverse the 'if' and 'else if' action line 67, because il you add an other {news} with 'category=""' parameter, the parameter wasn't take:

Code: Select all

if( isset($params['category_id']) )
  {
    $query1 .= " ( mnc.news_category_id = '".$params['category_id']."' ) AND ";
    $query2 .= " ( mnc.news_category_id = '".$params['category_id']."' ) AND ";
  }
else if
 (isset($params["category"]) && $params["category"] != '')
  {
    $category = cms_html_entity_decode(trim($params['category']));
    $categories = explode(',', $category);
    $query1 .= " (";
    $query2 .= " (";
    $count = 0;
    foreach ($categories as $onecat)
      {
	if ($count > 0)
	  {
	    $query1 .= ' OR ';
	    $query2 .= ' OR ';
	  }
	if (strpos($onecat, '|') !== FALSE || strpos($onecat, '*') !== FALSE)
	  {
	    $query1 .= "upper(mnc.long_name) like upper('" . trim(str_replace('*', '%', str_replace("'",'_',$onecat))) . "')";
	    $query2 .= "upper(mnc.long_name) like upper('" . trim(str_replace('*', '%', str_replace("'",'_',$onecat))) . "')";
	  }
	else
	  {
	    $query1 .= "mnc.news_category_name = '" . trim(str_replace("'",'_',$onecat)) . "'";
	    $query2 .= "mnc.news_category_name = '" . trim(str_replace("'",'_',$onecat)) . "'";
	  }
	$count++;
      }
    $query1 .= ") AND ";
    $query2 .= ") AND ";
  }

Could you tell me if it doesn't working on some version. Thanks!!  ;D