How do I make my Titles links? I have seen this in other blogs where the title will link like the permalink.
This is an archived forum and the content is probably no longer relevant, but is provided here for posterity.
The active forums are here.
March 19, 2008 10:02am
Subscribe [3]#1 / Mar 19, 2008 10:02am
How do I make my Titles links? I have seen this in other blogs where the title will link like the permalink.
#2 / Mar 19, 2008 10:07am
I just figured it out.
#3 / Apr 06, 2008 3:17pm
So share the solution with me!
#4 / Apr 06, 2008 3:24pm
Something like this should do it :
{exp:weblog:entries weblog="default_site" disable="member_data|trackbacks|categories|category_fields"}
<h2><a href="http://{url_title_path=template-group/template}" title="Read More - {title}">{title}</a></h2>
<p>{/exp:weblog:entries}You may need to swap out a few items in there such as default_site for your own weblog name if it is different and template-group/template needs to point to your template group and template and then you should be set 😉
Hope that helps.
Best wishes,
Mark
#5 / Apr 06, 2008 3:35pm
That’s cool - now how would i make them external URLs rather than links to my own pages?
#6 / Apr 06, 2008 3:44pm
Erm what for exactly? 😉
If you want external links in your templates then you would just hard-code these in. If you want to put an external link in an entry field then just type it in as you normally would either by doing this :
<a href="http://www.yahoo.com" title="Visit Yahoo">Visit Yahoo</a>or
[url="http://www.yahoo.com"]Visit Yahoo[/url]Above method uses PMCode like you would use in a forum
Hope that helps a bit? If I’m off track on what you need with this then do let me know and I will try again 😉
Best wishes,
Mark
#7 / Apr 06, 2008 3:47pm
Thanks Mark
What I’m trying to do is get the “title” field to be a link to a page on another site, but I don’t want the titles to be rendered as a URL on the page - I want them to just look like my styled h2 with no http etc.
Does that make sense?
#8 / Apr 06, 2008 3:56pm
Not entirely no but I think I get what you want 😉
The Title field in your entries should just be used to hold literally a title such as Yahoo. This will then be used as the text of the link. Next up you will want to use another field to hold the actual URL of the site that you want to get to. If you create a custom field in the weblog you are working in and call it something like weblog-name-external-url this will then hold the http://www.yahoo.com part of your link.
These can then be used in conjunction in a template in this way :
{exp:weblog:entries weblog="default_site" disable="member_data|trackbacks|categories|category_fields|pagination"}
<h2><a href="http://{weblog-name-external-url}" title="Visit - {title}">Visit - {title}</a></h2>
<p>{/exp:weblog:entries}This will then create you something like this on your page :
Hope that is what you are after? Are you creating some sort of link directory then?
Best wishes,
Mark
#9 / Apr 06, 2008 4:14pm
Mark
I appreciate your patience! Your example is pretty much what I want to achieve; the best example I can give is http://simplebits.com/ where the post titles take you straight off to the relevant site.
At the moment my code is
{exp:weblog:entries weblog="blog" limit="6"}
<h3><a href="http://{hyperlink}">{title}</a></h3>
<p> {linkSummary}</p>
<p> </p>
<p> <div class="date">{entry_date format="%M %d, %Y"}</div></p>
<p><br />
{/exp:weblog:entries}
Can you spot any obvious mistakes in there?
#10 / Apr 06, 2008 4:41pm
Hiya,
Right if you mean like on SImple Bits where he has the New UK coin designs link and so on and so forth then the code I provided should be working fine for you.
The only thing in my code that you will need to change is the name of {weblog-name-external-url} to reflect whatever custom field you are using to store your URL which in this case I guess is the {hyperlink} field?
So if your {hyperlink} field has http://www.yahoo.com saved in one of your entries with an entry title of Yahoo and you use this code below :
{exp:weblog:entries weblog="blog" limit="6"}
<h3><a href="http://{hyperlink}">{title}</a></h3>
<p>{linkSummary}<br />
<div class="date">{entry_date format="%M %d, %Y"}</div></p>
<p>{/exp:weblog:entries}You should then get what you are after. This will definitely get you exactly the same as the Simplbits site is doing part of the way down the page.
Just watching a film for the next 1 1/2 hours or so but will check back after that to see how you have got on with this.
Hope that helps?
Best wishes,
Mark
#11 / Apr 06, 2008 5:34pm
Mark
Thanks mate. I tried the code, and I still get the URL in full at the start of the post, and the link it has is
<code>http://localhost:8888/<a >
But even weirder is that when I update the post, the preview is fine. Do you think it could be something to do with the fact I’m developing the site locally, using MAMP on the Mac?
#12 / Apr 06, 2008 6:15pm
Hiya,
Hmm, without seeing the site I’m not really too sure what you are getting. Perhaps a screen-shot would help me out? 😉
On the other hand I’m wondering (without seeing exactly what you are seeing though 😉 ) if perhaps you have :
Admin->Weblog Administration->Weblog Management->Edit Preferences (Blog)->Weblog Posting Preferences->Automatically turn URLs and email addresses into links?
turned on?
If so then links will come out a bit weird. Also I am guessing that you may have :
Admin->Weblog Administration->Custom Weblog Fields->Add/Edit Custom Fields (Your Field Group that goes with the blog weblog)
I am thinking that perhaps your {hyperlink} field has its formatting preference set to XHTML as opposed to NONE?
If you set it to NONE and ensure you tick the check-box that appears at the bottom of the page before you submit your changes then I am fairly certain that hopefully your problems should all fade away! 😉
The code I have given definitely will work in the way that you want but I think you are seeing either one or both of the items I mention above. If you check both of them out and then see if that works hopefully you should be pleasantly surprised.
Best wishes,
Mark
#13 / Apr 06, 2008 6:46pm
Top man - thank you and goodnight!
#14 / Apr 06, 2008 6:48pm
I take it that worked then?
Best wishes,
Mark
#15 / Apr 06, 2008 6:49pm
It did - problem solved, thanks very much Mark.