Jump to content

Recommended Posts

it's because

 

$cms_titles variable is defined with:

$cms_titles = BlockCMSModel::getCMSTitles($column);

 

sql query for function looks like:

$sql = 'SELECT bcp.`id_cms`, cl.`name`, cl.`link_rewrite`
FROM `'._DB_PREFIX_.'cms_block_page` bcp
INNER JOIN `'._DB_PREFIX_.'cms_category_lang` cl
ON (bcp.`id_cms` = cl.`id_cms_category`)
WHERE bcp.`id_cms_block` = '.(int)$id_cms_block.'
AND cl.`id_lang` = '.(int)Context::getContext()->language->id.'
AND bcp.`is_category` = 1';

 

there is no content, so you have to modify the query to achieve what you want

Link to comment
Share on other sites

it's because

 

$cms_titles variable is defined with:

$cms_titles = BlockCMSModel::getCMSTitles($column);

 

sql query for function looks like:

$sql = 'SELECT bcp.`id_cms`, cl.`name`, cl.`link_rewrite`
FROM `'._DB_PREFIX_.'cms_block_page` bcp
INNER JOIN `'._DB_PREFIX_.'cms_category_lang` cl
ON (bcp.`id_cms` = cl.`id_cms_category`)
WHERE bcp.`id_cms_block` = '.(int)$id_cms_block.'
AND cl.`id_lang` = '.(int)Context::getContext()->language->id.'
AND bcp.`is_category` = 1';

 

there is no content, so you have to modify the query to achieve what you want

 

Entonces en el archivo blockCMSModel.php tengo que modificar cual function? pues getCMSTitles es:

 

 

public static function getCMSTitles($location, $id_shop = false)

{

$content = array();

$context = Context::getContext();

$cmsCategories = BlockCMSModel::getCMSCategoriesByLocation($location, $id_shop);

 

if (is_array($cmsCategories) && count($cmsCategories))

{

foreach ($cmsCategories as $cmsCategory)

{

$key = (int)$cmsCategory['id_cms_block'];

$content[$key]['display_store'] = $cmsCategory['display_store'];

$content[$key]['cms'] = BlockCMSModel::getCMSBlockPages($cmsCategory['id_cms_block']);

 

$links = array();

if (count($content[$key]['cms']))

{

foreach ($content[$key]['cms'] as $row)

{

$row['link'] = $context->link->getCMSLink((int)($row['id_cms']), $row['link_rewrite']);

$links[] = $row;

}

}

 

 

Tengo que modificar entonces getCMSBlockPages. Cierto?

 

 

public static function getCMSBlockPages($id_block)

{

$sql = 'SELECT cl.`id_cms`, cl.`meta_title`, cl.`link_rewrite`

FROM `'._DB_PREFIX_.'cms_block_page` bcp

INNER JOIN `'._DB_PREFIX_.'cms_lang` cl

ON (bcp.`id_cms` = cl.`id_cms`)

INNER JOIN `'._DB_PREFIX_.'cms` c

ON (bcp.`id_cms` = c.`id_cms`)

WHERE bcp.`id_cms_block` = '.(int)$id_block.'

AND cl.`id_lang` = '.(int)Context::getContext()->language->id.'

AND bcp.`is_category` = 0

AND c.`active` = 1

ORDER BY `position`';

 

return Db::getInstance()->executeS($sql);

}

 

$content[$key]['cms'] = $links;

$content[$key]['categories'] = BlockCMSModel::getCMSBlockPagesCategories($cmsCategory['id_cms_block']);

 

$links = array();

if (count($content[$key]['categories']))

{

foreach ($content[$key]['categories'] as $row)

{

$row['link'] = $context->link->getCMSCategoryLink((int)$row['id_cms'], $row['link_rewrite']);

$links[] = $row;

}

}

 

$content[$key]['categories'] = $links;

$content[$key]['name'] = $cmsCategory['block_name'];

$content[$key]['category_link'] = $context->link->getCMSCategoryLink((int)$cmsCategory['id_cms_category'], $cmsCategory['link_rewrite']);

$content[$key]['category_name'] = $cmsCategory['category_name'];

}

}

 

return $content;

}

Link to comment
Share on other sites

hello, can you use engish language here? if so, please correct your post, im convinced that many developers here don't know spanish as well as you :)

 

So, I need to modify the file blockCMSModel.php ? because the function getCMSTitles is:

 

public static function getCMSTitles($location, $id_shop = false)
{
$content = array();
$context = Context::getContext();
$cmsCategories = BlockCMSModel::getCMSCategoriesByLocation($location, $id_shop);
if (is_array($cmsCategories) && count($cmsCategories))
{
foreach ($cmsCategories as $cmsCategory)
{
$key = (int)$cmsCategory['id_cms_block'];
$content[$key]['display_store'] = $cmsCategory['display_store'];
$content[$key]['cms'] = BlockCMSModel::getCMSBlockPages($cmsCategory['id_cms_block']);
$links = array();
if (count($content[$key]['cms']))
{
foreach ($content[$key]['cms'] as $row)
{
$row['link'] = $context->link->getCMSLink((int)($row['id_cms']), $row['link_rewrite']);
$links[] = $row;
}
}

 

So I need fodify the funtion getCMSBlockPages ? that is

 

public static function getCMSBlockPages($id_block)
{
$sql = 'SELECT cl.`id_cms`, cl.`meta_title`, cl.`link_rewrite`
FROM `'._DB_PREFIX_.'cms_block_page` bcp
INNER JOIN `'._DB_PREFIX_.'cms_lang` cl
ON (bcp.`id_cms` = cl.`id_cms`)
INNER JOIN `'._DB_PREFIX_.'cms` c
ON (bcp.`id_cms` = c.`id_cms`)
WHERE bcp.`id_cms_block` = '.(int)$id_block.'
AND cl.`id_lang` = '.(int)Context::getContext()->language->id.'
AND bcp.`is_category` = 0
AND c.`active` = 1
ORDER BY `position`';
return Db::getInstance()->executeS($sql);
}
$content[$key]['cms'] = $links;
$content[$key]['categories'] = BlockCMSModel::getCMSBlockPagesCategories($cmsCategory['id_cms_block']);
$links = array();
if (count($content[$key]['categories']))
{
foreach ($content[$key]['categories'] as $row)
{
$row['link'] = $context->link->getCMSCategoryLink((int)$row['id_cms'], $row['link_rewrite']);
$links[] = $row;
}
}
$content[$key]['categories'] = $links;
$content[$key]['name'] = $cmsCategory['block_name'];
$content[$key]['category_link'] = $context->link->getCMSCategoryLink((int)$cmsCategory['id_cms_category'], $cmsCategory['link_rewrite']);
$content[$key]['category_name'] = $cmsCategory['category_name'];
}
}
return $content;
}

 

to

 

public static function getCMSBlockPages($id_block)
{
$sql = 'SELECT cl.`id_cms`, cl.`meta_title`, cl.`link_rewrite`, cl.`content`
FROM `'._DB_PREFIX_.'cms_block_page` bcp
INNER JOIN `'._DB_PREFIX_.'cms_lang` cl
ON (bcp.`id_cms` = cl.`id_cms`)
INNER JOIN `'._DB_PREFIX_.'cms` c
ON (bcp.`id_cms` = c.`id_cms`)
WHERE bcp.`id_cms_block` = '.(int)$id_block.'
AND cl.`id_lang` = '.(int)Context::getContext()->language->id.'
AND bcp.`is_category` = 0
AND c.`active` = 1
ORDER BY `position`';
return Db::getInstance()->executeS($sql);
}
$content[$key]['cms'] = $links;
$content[$key]['categories'] = BlockCMSModel::getCMSBlockPagesCategories($cmsCategory['id_cms_block']);
$links = array();
if (count($content[$key]['categories']))
{
foreach ($content[$key]['categories'] as $row)
{
$row['link'] = $context->link->getCMSCategoryLink((int)$row['id_cms'], $row['link_rewrite']);
$links[] = $row;
}
}
$content[$key]['categories'] = $links;
$content[$key]['name'] = $cmsCategory['block_name'];
$content[$key]['category_link'] = $context->link->getCMSCategoryLink((int)$cmsCategory['id_cms_category'], $cmsCategory['link_rewrite']);
$content[$key]['category_name'] = $cmsCategory['category_name'];
}
}
return $content;
}

Link to comment
Share on other sites

you hae to add content to the function:

$content[$key]['cms'] = BlockCMSModel::getCMSBlockPages($cmsCategory['id_cms_block']);

 

$sql = 'SELECT cl.`id_cms`, cl.`meta_title`, cl.`link_rewrite`, cl.content
FROM `'._DB_PREFIX_.'cms_block_page` bcp
INNER JOIN `'._DB_PREFIX_.'cms_lang` cl
ON (bcp.`id_cms` = cl.`id_cms`)
INNER JOIN `'._DB_PREFIX_.'cms` c
ON (bcp.`id_cms` = c.`id_cms`)
WHERE bcp.`id_cms_block` = '.(int)$id_block.'
AND cl.`id_lang` = '.(int)Context::getContext()->language->id.'
AND bcp.`is_category` = 0
AND c.`active` = 1
ORDER BY `position`';

Link to comment
Share on other sites

you hae to add content to the function: $content[$key]['cms'] = BlockCMSModel::getCMSBlockPages($cmsCategory['id_cms_block']);
 $sql = 'SELECT cl.`id_cms`, cl.`meta_title`, cl.`link_rewrite`, cl.content FROM `'._DB_PREFIX_.'cms_block_page` bcp INNER JOIN `'._DB_PREFIX_.'cms_lang` cl ON (bcp.`id_cms` = cl.`id_cms`) INNER JOIN `'._DB_PREFIX_.'cms` c ON (bcp.`id_cms` = c.`id_cms`) WHERE bcp.`id_cms_block` = '.(int)$id_block.' AND cl.`id_lang` = '.(int)Context::getContext()->language->id.' AND bcp.`is_category` = 0 AND c.`active` = 1 ORDER BY `position`';

 

 

Thanks!! :D

Link to comment
Share on other sites

×
×
  • Create New...