In Joomla 3.7.2, I have made an override of com_content/categories/default_items.php to show a default image if the category does not have an image like so:-
<?php if ($item->getParams()->get('image')) : ?>
<img src="<?php echo $item->getParams()->get('image'); ?>"/>
<?php elseif (($item->getParams()->get('image')) == null) : ?>
<?php echo "<img src=/defaultimage.png>"; ?>
<?php endif; ?>
This works and displays the default image for all categories (parents and child) which do not have an image set but I would like to modify this to only show the default image on subcategories, therefore the default image would not be displayed for top-level (i.e. root) categories.
How can I achieve this within this scope? I have tried the following:-
<?php if (($item->getParams()->get('image')) == null && ($item->parent_slug != '1:root')): ?>
<?php echo "<img src=/defaultimage.png>"; ?>
<?php endif; ?>
Unfortunately this returns the following error:-
Undefined property: JCategoryNode::$parent_slug in /templates/t3_bs3_blank/local/html/com_content/categories/default_items.php on line 41
The source of default_items.php is here. Thanks in advance for your assistance.