PDA

View Full Version : How to display a block once in category page and not listing page??



Santiago Blanco
January 12, 2015, 07:40 PM
Hello

I want to display a text block for SEO purposes in category page. But when i select the category the block also displays in the listing pages (ads).

Which is the form to only display once the textblock in the category page?.

Please help me because this is very important. Thanks.

Pete Young
January 12, 2015, 11:27 PM
Try using the banner pluggin, there is the option to place blocks above each category and you can enable those blocks in text format.

Viktor
January 13, 2015, 06:37 AM
Hello Santiago,

We changed some logic of selecting blocks. And if you want I can send you code here or you can create a ticket and I will change code myself free for you :)

Santiago Blanco
January 13, 2015, 06:09 PM
Please help me with the code. It is very important for SEO pursposes to only show once that text. Thank you Viktor

Curtis
January 14, 2015, 04:34 AM
Please help me with the code. It is very important for SEO pursposes to only show once that text. Thank you Viktor

Hello Santiago,

Try make the following:
1. open file: /includes/classes/rlCommon.class.php
2. find the function getBlocks(), row ~1105
3. and replace code of this function:


function getBlocks()
{
global $page_info, $config;

if ( $config['mod_rewrite'] )
{
$category_path = $_GET['rlVareables'];
$category_id = 0;

if ( !empty($category_path) )
{
if ( $_GET[$config['mod_rewrite'] ? 'listing_id' : 'id'] )
{
$category_path = preg_replace( '/\/[^\/]*$/', '', trim($category_path,'/') );
}
$this -> rlValid -> sql($category_path);

/* get category id */
$category_id = (int)$this -> getOne('ID', "`Path` = CONVERT('{$category_path}' USING utf8)", 'categories');
}
}
else
{
$category_id = (int)$_GET['category'];
}

/* redefine page ID with listing details page ID, 25 in this case */
if ( $page_info['Controller'] == 'listing_type' && $_GET[$config['mod_rewrite'] ? 'listing_id' : 'id'] )
{
$page_info['ID'] = 25;
}

if ( $page_info['Controller'] == 'listing_type' )
{
if ($additional = $this -> detectParentIncludes($category_id))
{
$add_where = "OR (FIND_IN_SET('{$additional}', `Category_ID`) > 0 AND `Subcategories` = '1')";
}

$sql = "SELECT `ID`, `Key`, `Side`, `Type`, `Content`, `Tpl` FROM `". RL_DBPREFIX ."blocks`";
$sql .= "WHERE (`Sticky` = '1' OR ";

if ( $category_id && $page_info['ID'] != 25 )
{
$sql .= "((`Category_ID` <> '' AND FIND_IN_SET('{$category_id}', `Category_ID`) > 0) OR `Cat_sticky` = '1' {$add_where}) ";
}
else
{
$sql .= "FIND_IN_SET( '{$page_info['ID']}', `Page_ID` ) > 0 ";
}

$sql .= ") ";

$sql .= "AND `Status` = 'active' {$where} ";
$sql .= "ORDER BY `Position` ";

$tmp_blocks = $this -> getAll($sql);
}
else
{
$tmp_blocks = $this -> fetch( array('ID', 'Key', 'Side', 'Type', 'Content', 'Tpl'), array( 'Status' => 'active' ), "AND (FIND_IN_SET( '{$page_info['ID']}', `Page_ID` ) > '0' OR `Sticky` = '1') {$where} ORDER BY `Position`", null, 'blocks' );
}

if ( !empty($tmp_blocks) )
{
foreach ($tmp_blocks as $key => $value)
{
$block_keys[$value['Key']] = true;

$blocks[$value['Key']] = $value;
if ( $value['Type'] == 'html' )
{
$blocks[$value['Key']]['Content'] = $GLOBALS['lang']['blocks+content+'.$value['Key']];
}
}

unset($tmp_blocks);
$this -> block_keys = $block_keys;

$blocks = $this -> rlLang -> replaceLangKeys($blocks, 'blocks', array('name'));
$this -> defineBlocksExist($blocks);
}

return $blocks;
}

4. after go to the admin panel and edit your exist box: unselect the listing type page in show on pages section and select the categories only
5. save box and check

Santiago Blanco
January 14, 2015, 08:27 AM
Superb, thank you very much Curtis. It works like a charm!.

http://planetaescorts.es/