How To Use Article Title As External URL??

General questions relating to Joomla! 3.x.

Moderator: General Support Moderators

Forum rules
Forum Rules
Absolute Beginner's Guide to Joomla! <-- please read before posting.
Forum Post Assistant - If you are serious about wanting help, you should use this tool to help you post.
Windows Defender SmartScreen Issues <-- please read this if using Windows 10
Locked
feliwebwork
Joomla! Apprentice
Joomla! Apprentice
Posts: 10
Joined: Tue Aug 12, 2014 1:44 am

How To Use Article Title As External URL??

Post by feliwebwork » Thu Jun 16, 2016 4:04 pm

Hi Friends,

I am trying to figure out how to link some article titles to external urls so that when someone clicks on the article title, it takes them to that external url and not to the article itself. This is for a news aggretator website that I am working on.

I found a solution that was offered for Joomla 1.5 here:
http://forum.joomla.org/viewtopic.php?t=521333#p3338062

It seems the suggestion is to use the external reference input as the source of the external url. This seems like a good idea. However, it seems that Joomla 3.5 is quite different, and I am not very skilled, so I would appreciate any help others can offer.

Could someone help me (and others) in having the option of linking some article titles to external urls??

Thanks for any help you can offer.

itoctopus
Joomla! Virtuoso
Joomla! Virtuoso
Posts: 4026
Joined: Mon Nov 25, 2013 4:35 pm
Location: Montreal, Canada
Contact:

Re: How To Use Article Title As External URL??

Post by itoctopus » Thu Jun 16, 2016 6:23 pm

You can store the link that you want the users to redirect to in Link A (for example) under "Images and Links" (when editing the article). You can then override the article layout and use that link (Link A) instead of the default link. Link A is stored in json format in $this->item->urls .
http://www.itoctopus.com - Joomla consulting at its finest
https://twitter.com/itoctopus - Follow us on Twitter

feliwebwork
Joomla! Apprentice
Joomla! Apprentice
Posts: 10
Joined: Tue Aug 12, 2014 1:44 am

Re: How To Use Article Title As External URL??

Post by feliwebwork » Thu Jun 16, 2016 7:37 pm

Hi, Thanks for your response and guidance.

I found where to put the link in "Images and Links". But then I was stuck for how to override the article layout and use that link instead of the default link.

I found the default.php file in com_content/views/article/default.php and I assumed this was the one I need to copy over to my template and edit??

I found the code that says

Code: Select all

$urls = json_decode($this->item->urls);


but I'm not sure what I am supposed to do with that now. I can't find the code that links the title so that I can tell it to link to $urls, nor how to do it exactly.

Please forgive my newbyness. Any step by step direction you can offer is greatly appreciated. Thanks.

feliwebwork
Joomla! Apprentice
Joomla! Apprentice
Posts: 10
Joined: Tue Aug 12, 2014 1:44 am

Re: How To Use Article Title As External URL??

Post by feliwebwork » Fri Jun 17, 2016 3:32 pm

I think I found the override file that deals with the titles in the blog category:

[my-template]/layouts/joomla/content/blog_style_default_item_title.php

In lines 23-28 I found:

Code: Select all

<?php if ($params->get('link_titles') && $params->get('access-view')) : ?>
						<a href="<?php echo JRoute::_(ContentHelperRoute::getArticleRoute($displayData->slug, $displayData->catid, $displayData->language)); ?>" itemprop="url">
						<?php echo $this->escape($displayData->title); ?></a>
					<?php else : ?>
						<?php echo $this->escape($displayData->title); ?>
					<?php endif; ?>
I tried changing the link to <a href="whatever"> but the result is that the title link now directs as:

http://[mywebsite]/whatever

What I really want to do is to change the whole link to "whatever" without it calling my main site first.

Does anyone know how to do that?

The second step would then be to make the link call the Link A data that @itoctupus mentioned above.

Any help with this is greatly appreciated. Thank you.

websquirrel
Joomla! Apprentice
Joomla! Apprentice
Posts: 12
Joined: Fri Jul 13, 2012 6:17 pm

Re: How To Use Article Title As External URL??

Post by websquirrel » Tue Feb 20, 2018 8:50 pm

I have exact the seem problem and would be happy if anyone had a solution or advice. How is it possible to replace the default title link by link A?


Locked

Return to “General Questions/New to Joomla! 3.x”