New answers tagged

1

Although using content plugin works, there is no need for it in PHP code. Instead you can use the document renderer directly: use Joomla\CMS\Factory; echo Factory::getApplication()->getDocument()->loadRenderer('modules')->render($position);


0

If you want loadposition to load only once in the Blog view then you need to do an if statement in components/com_content/views/category/tmpl/blog.php Here's the line where it counts the articles https://github.com/joomla/joomla-cms/blob/staging/components/com_content/views/category/tmpl/blog.php#L72 <?php $leadingcount = 0; ?> 0 is the first one....


0

I gave up on this in the end and requested the client manually add the placeholder image when creating the post. Thank you all for your contributions.


1

Another idea is to initialize an $image variable earlier in your script like so: $image = $item->image ? $item->image : 'images/placeholder.jpg'; The $image will get the value of the $item->image if it's set, or the placeholder file path you set. Then you use the $image variable in place of the $item->image in your script. *You won't need the ...


1

Your are missing brackets around else: <?php if ($item->image) { ?> ... <?php } else { ?> ... <?php } ?> You may also give alternative syntax a try, see if it's more readable to you: <?php if ($item->image) : ?> ... <?php else : ?> ... <?php endif; ?>


Top 50 recent answers are included