[Solved] Style an article from its category - Joomla! Forum - community, help and support
hi everyone,
i know how different style article depending on category from. pretty sure has been asked several times before, , i've found answers, none of them seemed work. maybe changed joomla 3.0 ?
anyway, have idea how want it. add class container of article. class categoryid or category name, prefer former.
the problem don't know how call categoryid/name of article using php.
any idea ?
i know how different style article depending on category from. pretty sure has been asked several times before, , i've found answers, none of them seemed work. maybe changed joomla 3.0 ?
anyway, have idea how want it. add class container of article. class categoryid or category name, prefer former.
the problem don't know how call categoryid/name of article using php.
any idea ?
create template override for
/components/com_content/views/article/tmpl/default.php contains
<div class="<?php echo $this->escape($this->item->title)?>">
is category of article, if category of article called mycars ... output be
<div class="mycars">
therefore .mycars need in css file
the draw if had category names spaces because
<div class="my cars">
would awkward css. css need .my or .cars
<div class="<?php echo $this->escape($this->item->parent_title)?>">
is similar returns parent category of article. if category 'my cars' had 'vehicles' parent then
<div class="vehicles">
would out put
in override file
/templates/yourdefaulttemplate/html/com_content/views/article/default.php
(notice there no /tmpl in path)
on line 24
replace
<div class="item-page<?php echo $this->pageclass_sfx?>">
with
<div class="<?php echo $this->escape($this->item->title)?>">
or
<div class="<?php echo $this->escape($this->item->parent_title)?>">
methinks if still want page class suffix available then
<div class="<?php echo $this->escape($this->item->title); echo $this->pageclass_sfx?>">
will work.
addendum
perhaps use
<div class="item-page <?php echo $this->escape($this->item->title)?>">
would better render as
<div class="item-page cars">
and prevent breaking existing css .item-page
/components/com_content/views/article/tmpl/default.php contains
<div class="<?php echo $this->escape($this->item->title)?>">
is category of article, if category of article called mycars ... output be
<div class="mycars">
therefore .mycars need in css file
the draw if had category names spaces because
<div class="my cars">
would awkward css. css need .my or .cars
<div class="<?php echo $this->escape($this->item->parent_title)?>">
is similar returns parent category of article. if category 'my cars' had 'vehicles' parent then
<div class="vehicles">
would out put
in override file
/templates/yourdefaulttemplate/html/com_content/views/article/default.php
(notice there no /tmpl in path)
on line 24
replace
<div class="item-page<?php echo $this->pageclass_sfx?>">
with
<div class="<?php echo $this->escape($this->item->title)?>">
or
<div class="<?php echo $this->escape($this->item->parent_title)?>">
methinks if still want page class suffix available then
<div class="<?php echo $this->escape($this->item->title); echo $this->pageclass_sfx?>">
will work.
addendum
perhaps use
<div class="item-page <?php echo $this->escape($this->item->title)?>">
would better render as
<div class="item-page cars">
and prevent breaking existing css .item-page
Comments
Post a Comment