Help with J3 override of blog layout

Everything to do with Joomla! 3.x templates and templating.

Moderator: General Support Moderators

Forum rules
Forum Rules
Absolute Beginner's Guide to Joomla! <-- please read before posting, this means YOU.
Forum Post Assistant - If you are serious about wanting help, you will use this tool to help you post.
Windows Defender SmartScreen Issues <-- please read this if using Windows 10.
Post Reply
User avatar
avocom
Joomla! Apprentice
Joomla! Apprentice
Posts: 22
Joined: Mon Apr 06, 2009 9:59 am
Location: Sydney, Australia
Contact:

Help with J3 override of blog layout

Post by avocom » Fri Jan 07, 2022 12:59 am

Hello,

After a long time I'm back trying to do this and it appears much have changed. I have done overrides before and layouts too.

I have a standard blog page where I want the titles and intro images to be a link to the Link A provided in the article if this is present. It shouldn't be hard. Just find where the title and intro image is and add a link to it.
Here is the problem. I can't find it. It appears all content now is generated by plugins. Some help of which file to override would be awesome. And if you know how to access the Link A from the article, please help too :)

Thank you

Joomla 3.10.4
PHP 7.4.27
'The sprig of acacia, at the head of the grave, refers to the immortality of the soul'
http://www.avocom.com.au

User avatar
toivo
Joomla! Master
Joomla! Master
Posts: 13976
Joined: Thu Feb 15, 2007 5:48 am
Location: Sydney, Australia

Re: Help with J3 override of blog layout

Post by toivo » Fri Jan 07, 2022 3:32 am

avocom wrote:
Fri Jan 07, 2022 12:59 am
I want the titles and intro images to be a link to the Link A provided in the article if this is present.
One could work out the logic how a content plugin could use the Document Object Model (DOM) or the article object and alter the HTML code of the <img> tag on the fly. However, IMHO, most webmasters would leave that task to their editors to do manually.

avocom wrote:
Fri Jan 07, 2022 12:59 am
It appears all content now is generated by plugins.
That is not necessarily the case, unless the website is using some content builder or page builder extension. Normal Joomla articles can still be edited by hand by administrators from the back end and by authors, editors and publishers from the front end.

avocom wrote:
Fri Jan 07, 2022 12:59 am
And if you know how to access the Link A from the article, please help too
Here is an example of Link A in the HTML code in Protostar in 3.10.4:

Code: Select all

<div class="content-links">
	<ul class="nav nav-tabs nav-stacked">
					<li class="content-links-a">
				<a href="http://www.bom.gov.au" target="_blank" rel="nofollow noopener noreferrer">Bureau of Meteorology</a>				</li>
			</ul>
</div>
Even though a content plugin could access the contents of Link A through the DOM, it would be simpler to grab the column 'urls' from the article object, decode the JSON format and check the item 'urla', as shown below:

Code: Select all

{"urla":"http:\/\/www.bom.gov.au","urlatext":"Bureau of Meteorology","targeta":"1","urlb":false,"urlbtext":"","targetb":"","urlc":false,"urlctext":"","targetc":""}
Here are a couple of tutorials about overrides and layouts as reference:
How to use the Template Manager to create overrides
How to override the output from the Joomla code
Layout Overrides in Joomla
Toivo Talikka, Global Moderator

User avatar
avocom
Joomla! Apprentice
Joomla! Apprentice
Posts: 22
Joined: Mon Apr 06, 2009 9:59 am
Location: Sydney, Australia
Contact:

Re: Help with J3 override of blog layout

Post by avocom » Fri Jan 07, 2022 6:36 am

Thanks very much for your comments.

I'm now working on com_content/category/blog_item.php and it has a lot of code generated by JLayoutHelper::render, but I'm hoping I can just wrap it all in a link.

Do you know how I can reference the article Link A to create a link around the elements? How can I access this article parameter and use in this page. I guess it would be $params->get('something') or $params->item->something

thank you
'The sprig of acacia, at the head of the grave, refers to the immortality of the soul'
http://www.avocom.com.au

User avatar
toivo
Joomla! Master
Joomla! Master
Posts: 13976
Joined: Thu Feb 15, 2007 5:48 am
Location: Sydney, Australia

Re: Help with J3 override of blog layout

Post by toivo » Fri Jan 07, 2022 7:38 am

The Link A data is available from the article object. As a test, add the following lines after line 24 of blog_item.php and you will see the raw JSON string, then the decoded object and the properties of Link A:

Code: Select all

$urls_json 	= $this->item->urls;
echo '<br>urls = ' . $urls_json . '<br>';
$urls = json_decode($urls_json);
echo '<br>' . print_r($urls, true) . '<br>';
echo '<br>Link A = ' . $urls->urla . '<br>Link A Text = ' . $urls->urlatext . '<br>URL Target Window = ' . $urls->targeta . '<br>';
This is an example of the output at the top of a blog article:
links.jpg
You do not have the required permissions to view the files attached to this post.
Toivo Talikka, Global Moderator

User avatar
avocom
Joomla! Apprentice
Joomla! Apprentice
Posts: 22
Joined: Mon Apr 06, 2009 9:59 am
Location: Sydney, Australia
Contact:

Re: Help with J3 override of blog layout

Post by avocom » Tue Jan 11, 2022 4:30 am

Thanks very much. Thats the info I needed to be able to refer to the links!!

The only thing I couldn't find, is the info on the Global settings for the link targets. With the urls we can get what has been set in the article fields, but if it is left as Use Global, the target comes empty. I coded a work around, but it would neat to cater the override for the Global setting too.

Thanks again
'The sprig of acacia, at the head of the grave, refers to the immortality of the soul'
http://www.avocom.com.au

User avatar
toivo
Joomla! Master
Joomla! Master
Posts: 13976
Joined: Thu Feb 15, 2007 5:48 am
Location: Sydney, Australia

Re: Help with J3 override of blog layout

Post by toivo » Tue Jan 11, 2022 7:24 am

The selection of 'URL A Target Window' can be retrieved from 'Articles: Options':

Code: Select all

echo '<br>targeta = ' . $params->get('targeta');
Here are the values of 'targeta':
  • 0 Open in parent window
  • 1 Open in new window
  • 2 Open in popup
  • 3 Modal
Toivo Talikka, Global Moderator

User avatar
avocom
Joomla! Apprentice
Joomla! Apprentice
Posts: 22
Joined: Mon Apr 06, 2009 9:59 am
Location: Sydney, Australia
Contact:

Re: Help with J3 override of blog layout

Post by avocom » Tue Jan 11, 2022 10:48 pm

toivo wrote:
Tue Jan 11, 2022 7:24 am
The selection of 'URL A Target Window' can be retrieved from 'Articles: Options':

Code: Select all

echo '<br>targeta = ' . $params->get('targeta');
Thank you and yes, this is what I'm doing without issues. What I don't know is how to retrieve the "Use Global" setting. When no target is selected at article level, the

Code: Select all

targeta
comes empty and it would be nice to use the option from the global settings instead in that case.

Cheers
'The sprig of acacia, at the head of the grave, refers to the immortality of the soul'
http://www.avocom.com.au

User avatar
toivo
Joomla! Master
Joomla! Master
Posts: 13976
Joined: Thu Feb 15, 2007 5:48 am
Location: Sydney, Australia

Re: Help with J3 override of blog layout

Post by toivo » Tue Jan 11, 2022 11:13 pm

What do you mean? The value of 'targeta' of each article is in the article object and the value of 'Articles: Options' is the global setting in the $params object.
Toivo Talikka, Global Moderator


Post Reply

Return to “Templates for Joomla! 3.x”