article external link title

General questions relating to Joomla! 1.5 There are other boards for more specific help on Joomla! features and extensions.

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.
Locked
claudito
Joomla! Apprentice
Joomla! Apprentice
Posts: 6
Joined: Thu Nov 12, 2009 11:00 am

article external link title

Post by claudito » Mon May 31, 2010 5:02 pm

hello

usually to create a link to an external resource must first create an article
the user to go to the external resource in first time must enter in the article and then click on to external resources.
I need that article title link is directly to the external resource.
like when you create a menu link
is it possible?

User avatar
westiefan
Joomla! Intern
Joomla! Intern
Posts: 64
Joined: Wed May 19, 2010 3:04 pm
Location: Hampshire, UK
Contact:

Re: article external link title

Post by westiefan » Mon May 31, 2010 5:12 pm

Can you give an example of what you are trying to do here?

claudito
Joomla! Apprentice
Joomla! Apprentice
Posts: 6
Joined: Thu Nov 12, 2009 11:00 am

Re: article external link title

Post by claudito » Mon May 31, 2010 6:22 pm

i would create an article(empty) with the title that link to an external resource.
as when we create a menu item and we link to a external url.

sorry for my english :)

User avatar
westiefan
Joomla! Intern
Joomla! Intern
Posts: 64
Joined: Wed May 19, 2010 3:04 pm
Location: Hampshire, UK
Contact:

Re: article external link title

Post by westiefan » Tue Jun 01, 2010 1:01 am

Ok. I think I understand you here.

To link to an external URL you do not need to create an article first, all you need to do here is to create a new menu item, and instead of selecting an "Article" type, you select an "External Link" type menu item, and then enter the full URL and select the paramemters and settings etc (e.g. to open a new window etc).

That should be all there is to it, unless I am missing your point here.

claudito
Joomla! Apprentice
Joomla! Apprentice
Posts: 6
Joined: Thu Nov 12, 2009 11:00 am

Re: article external link title

Post by claudito » Tue Jun 01, 2010 6:40 am

ok. this is to create a menu item. there is this function for article titles?
I want to connect the title of an article to an url

like the mainpage of the site http://xxx
Last edited by claudito on Tue Jun 01, 2010 12:11 pm, edited 1 time in total.

User avatar
westiefan
Joomla! Intern
Joomla! Intern
Posts: 64
Joined: Wed May 19, 2010 3:04 pm
Location: Hampshire, UK
Contact:

Re: article external link title

Post by westiefan » Tue Jun 01, 2010 12:04 pm

Hmm! I looked at your example site, and it is definitely NOT a Joomla site.

I don't think that you can link the titles directly to an external URL, as the "Title Linkable" setting (in the "Advanced" parameters) refers to a link to the full article (in the case of a "read more" link).

What I would do in this case is to switch off the titles, and then set up my own page titles in "<h1>" tags at the head of the article, and then create this as a standard link, and then there are no limitations as to how you can link it (be it an internal or an external link).

I hope this helps.

claudito
Joomla! Apprentice
Joomla! Apprentice
Posts: 6
Joined: Thu Nov 12, 2009 11:00 am

Re: article external link title

Post by claudito » Tue Jun 01, 2010 12:12 pm

It' simple !!! Great idea westiefan. tnx :)

User avatar
westiefan
Joomla! Intern
Joomla! Intern
Posts: 64
Joined: Wed May 19, 2010 3:04 pm
Location: Hampshire, UK
Contact:

Re: article external link title

Post by westiefan » Tue Jun 01, 2010 12:30 pm

You're welcome.

marie12
Joomla! Fledgling
Joomla! Fledgling
Posts: 2
Joined: Tue Sep 08, 2009 2:09 pm

Re: article external link title

Post by marie12 » Thu Sep 23, 2010 4:58 pm

Hello,
In the menu, I would like to set my external link, particulary to have an attribute "title"
(like in HTML for a link : <a href="#" title="my text">)
because I want to have a yellow block with my text in it when I hover the link.
Is it possible in Joomla ?
Thank you in advance for your reply.

eddie01001
Joomla! Enthusiast
Joomla! Enthusiast
Posts: 111
Joined: Fri Feb 14, 2014 3:21 am

Re: article external link title

Post by eddie01001 » Fri Oct 23, 2015 7:54 pm

It seems that there is quite a handful of people who have been asking or thinking about the possibility to use articles as a menu item that would open external urls when clicked on. I see that this question has popped up here and there for other templates on this forum, all which remains unsolved as there is simply no plugin that can perform this perfectly or flexible enough to control whether a pop up or new tab is used.

Thus I'm writing this guide to help solve this problem for you. For the sake of compatibility with Joomla & Joomlart templates, this guide will only provide instructions for Joomla articles, and applies to Joomla 2.5 only *since there are no template for 3.0 yet* =) It can also be done for K2 btw but I'll create a separate thread with K2 code if there's request for it.

This guide is abit long since it will cover the code modification for Image Link, Title Link & Read More link. I'll break it down into simple steps so you can understand the flow of the code. Well then, let us begin!

Important note: This code modification is only done for template files. There is no need to hack Joomla core so it should be update safe =)

The guide starts here if you are too lazy to read my commentary above.

1) Go to article manager, add/edit an article.
2) Look under metadata options, there should be a field called "External Reference".
3) Joomla don't really uses this field and infact it's quite undocumented but it's purpose is to pull meta information from external site such as Wikipedia sources. Still since we're going to be opening the external link, it doesn't matter. So let's put the external URL in there, for example http://www.example.com/

Now, we need to modify the template file to call this field and extract the URL that was entered. Actually, you can even enter other values in this field as well and use the value to perform checks, so you can use it to do something else if you get my drift =) So this guide applies to alot more possibilities.

Open com_content\category\blog_item.php and find this line of code:
Code:
$xclass = $metadataParams->get('xclass');
That's for extended classes and below there, we will call add another line of code to call the value of "External reference". So it looks like this
Code:
$xclass = $metadataParams->get('xclass');
$xref = $metadataParams->get('xreference');
Now we have placed the url in the variable $xref and this part only needs to be done once for this php file so let us move on to create a check to determine the article link to use if $xref is not empty.

Read More Button
Still in blog_item.php find this block of code. I'll give the example for readmore button first as it's the easiest to understand.

Code:
<p class="readmore">
<a href="<?php echo $link; ?>" title="<?php echo $atitle ?>" class="item-link">
Now we'll create the check and replace that block of code with this
Code:
<p class="readmore">
<?php if (!empty($xref)): ?>
<a href="<?php echo $xref; ?>" target="_blank" title="<?php echo $atitle ?>">
<?php else : ?>
<a href="<?php echo $link; ?>" title="<?php echo $atitle ?>" class="item-link">
<?php endif; ?>
Now it will check if "External Reference" is empty. If it's not empty, it will use the url as the article's link and open in a new tab. Note that I have remove class="item-link" so it won't open in pop up (It's used in JA Wall, if you're using other templates, you can remove class="item-link" ). But if "External Reference" is empty, it will use the default article link =) That should do what you want to perfectly and it's very flexible to make or add additional changes.


Article Title
Ok so now on the article title, also still in blog_item.php, look for this code. It gets slightly complicated so I'll show the entire block code.
Code:
<?php if ($params->get('link_titles') && $params->get('access-view')) : ?>
<a href="<?php echo $link; ?>" title="<?php echo $atitle ?>" class="item-link">
<?php echo $atitle ?></a>
<?php else : ?>
<?php echo $atitle ?>
<?php endif; ?>
Once again we'll create a check if $xref is empty and echo the url to use. Replace the block above with this block below.
Code:
<?php if ($params->get('link_titles') && $params->get('access-view')) : ?>
<?php if (!empty($xref)): ?>
<a href="<?php echo $xref; ?>" target="_blank" title="<?php echo $atitle ?>">
<?php echo $atitle ?></a>
<?php else : ?>
<a href="<?php echo $link; ?>" title="<?php echo $atitle ?>" class="item-link">
<?php echo $atitle ?></a>
<?php endif; ?>
<?php else : ?>
<?php echo $atitle ?>
<?php endif; ?>

Image Link

Hang in there! We're almost done here. Just left the image link to do. Once again, still in blog_item.php, look for this block of code.
Code:
<div class="item-image">
<?php if (isset($images->image_intro) and !empty($images->image_intro)) : ?>
<?php $imgfloat = (empty($images->float_intro)) ? $params->get('float_intro') : $images->float_intro; ?>
<div class="img-intro-<?php echo htmlspecialchars($imgfloat); ?>">
<?php if ($params->get('link_titles') && $params->get('access-view')) : ?>
<a href="<?php echo $link; ?>" title="<?php echo $atitle ?>" class="item-link">
<?php endif; ?>
<img
<?php if ($images->image_intro_caption):
echo 'class="caption"'.' title="' .htmlspecialchars($images->image_intro_caption) .'"';
endif; ?>
src="<?php echo htmlspecialchars($images->image_intro); ?>" alt="<?php echo htmlspecialchars($images->image_intro_alt); ?>"/>
<?php if ($params->get('link_titles') && $params->get('access-view')) : ?>
<span>&nbsp;</span>
<span class="item-pin">&nbsp;</span>
</a>
<?php endif; ?>
</div>
<?php endif; ?>
</div>
Wow that's alot of code! But actually, we're just modifying this one line within that block of code. Wait, I'm just showing an example, I haven't add the modification yet.
Code:
<a href="<?php echo $link; ?>" title="<?php echo $atitle ?>" class="item-link">
This is how the line looks like after modification. Just replace that 1 line of code with this and you are done =)
Code:
<?php if (!empty($xref)): ?>
<a href="<?php echo $xref; ?>" target="_blank" title="<?php echo $atitle ?>">
<?php else : ?>
<a href="<?php echo $link; ?>" title="<?php echo $atitle ?>" class="item-link">
<?php endif; ?>
And with that, the whole modification is complete. Aren't it simple? ^_^ If this customization has been of help to you, please thank the post and also share your modification or modification in JA Wall Guides so fellow wall builders can help one another and make this an even better template!

P.S: In case for some reason you don't understand the purpose of this guide. The end result of this modification would be that, clicking on readmore, image & title of any wall article would open them in a new tab. The url of the new tab will be the value defined in "External Reference".

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

Re: article external link title

Post by feliwebwork » Fri Jun 17, 2016 4:59 pm

@eddie01001 any chance your method could be updated to Joomla 3? I am trying to work it out, but I am not able to, and I am not getting much response in the forum.

Any help you can give would be greatly appreciated.

narutositinh
Joomla! Fledgling
Joomla! Fledgling
Posts: 3
Joined: Thu Aug 18, 2016 12:10 pm

Re: article external link title

Post by narutositinh » Thu Aug 18, 2016 12:24 pm

I also am having similar problems have yet to be processed :((


Locked

Return to “General Questions/New to Joomla! 1.5”