customising the auto limk generation…
Posted: 28 November 2008 04:57 AM   [ Ignore ]  
Grad Student
Avatar
Rank
Total Posts:  57
Joined  11-25-2008

in a custom field ‘brandUrl’
I’ve got a url in full format:
http://www.123.com etc

All good, but my boss just asked that I display them in a list, without the http:// bit.

if I was usig strict PHP, I’d use substr but I can’t here..

Also, out of interest, but can I specify a completly different text for the anchor tag?

so if my weblog entry is:
http://www.123.com

I wanna output:
<a href=“http://www.123.com”>Whatever text I want…</a>

Both of these MUSt be possible.. but searching the how to for:
custom links
format anchor tags
turns up nothing… :-(

Profile
 
 
Posted: 28 November 2008 05:26 AM   [ Ignore ]   [ # 1 ]  
Grad Student
Avatar
Rank
Total Posts:  77
Joined  06-27-2008

take a look at the parse_url plugin

Beispiel: {exp:parse_url parts=“host”}{your_url}{/exp:parse_url}
the parts parameter let’s you decide what you want to include…

cheers
stefan

Profile
 
 
Posted: 28 November 2008 05:40 AM   [ Ignore ]   [ # 2 ]  
Grad Student
Avatar
Rank
Total Posts:  57
Joined  11-25-2008

Nice… but that doesn’t let me change the link text…

I think I also beed to add a class to that link…
I’ll see if I’ve read it right…

Profile
 
 
Posted: 28 November 2008 05:54 AM   [ Ignore ]   [ # 3 ]  
Grad Student
Avatar
Rank
Total Posts:  77
Joined  06-27-2008
Beertastic - 28 November 2008 05:40 AM

Nice… but that doesn’t let me change the link text…

I think I also beed to add a class to that link…
I’ll see if I’ve read it right…

for a custom link text, make two custom fields in the weblog (your-weblog)
for instance one custom field called
link-url where you put your http://www.link.com…
and another one: link-text

then use the following syntax:

{exp:weblog:entries weblog="your-weblog" disable="categories|member_data|trackbacks"}
    
<a href="{link-url}" title="{link-text}" class="your-class">{link-text}</a><hr />
{/exp:weblog:entries}

this will list all of your links in the corresponding weblog
hope this helps

stefan

Profile
 
 
Posted: 28 November 2008 05:56 AM   [ Ignore ]   [ # 4 ]  
Grad Student
Avatar
Rank
Total Posts:  77
Joined  06-27-2008

or if you want to combine both:

{exp:weblog:entries weblog="your-weblog" disable="categories|member_data|trackbacks"}
    
<a href="{link-url}" title="{link-text}" class="your-class">{exp:parse_url parts=“host”}{link-url}{/exp:parse_url} - {link-text}</a><hr />
{/exp:weblog:entries}

cheers

Profile
 
 
Posted: 28 November 2008 06:05 AM   [ Ignore ]   [ # 5 ]  
Grad Student
Avatar
Rank
Total Posts:  57
Joined  11-25-2008

I’ll give that a go..
so does that mean if I wanna use a link all over my site..
but have the links text be different..
eg:
click here
visit the site
read more
etc..
I’d have to have a different link text field for each entry..?

I find that very limiting and can’t believe I’m the first person to want more control over my links…?

Still, it’s a start… I’ll get adding..
cheers all…

Profile
 
 
Posted: 28 November 2008 06:34 AM   [ Ignore ]   [ # 6 ]  
Grad Student
Avatar
Rank
Total Posts:  77
Joined  06-27-2008

sorry, I was only referring to this:

Beertastic - 28 November 2008 04:57 AM

in a custom field ‘brandUrl’
I’ve got a url in full format:
http://www.123.com etc
All good, but my boss just asked that I display them in a list, without the http:// bit.

Profile
 
 
Posted: 28 November 2008 06:37 AM   [ Ignore ]   [ # 7 ]  
Grad Student
Avatar
Rank
Total Posts:  77
Joined  06-27-2008

I would look into path variables:
here and here and here and of course here

Profile
 
 
Posted: 28 November 2008 06:39 AM   [ Ignore ]   [ # 8 ]  
Grad Student
Avatar
Rank
Total Posts:  77
Joined  06-27-2008
Beertastic - 28 November 2008 06:05 AM

I’ll give that a go..

eg:
click here
visit the site
read more
etc..
I’d have to have a different link text field for each entry..?

no no, you can do it directely in the template!
cheers
stefan

Profile
 
 
Posted: 28 November 2008 06:53 AM   [ Ignore ]   [ # 9 ]  
Grad Student
Avatar
Rank
Total Posts:  57
Joined  11-25-2008

Ah, still doesn’t work…
i’ve got several URLs in teh weblog..
fomatted
http://www.123.com

None of the above examples allow me to output:
<a href=“http://www.123.com”>MY CUSTOM TEXT</a>

that’s all I’m after..
No paths relative to teh CMS at all..
just external links..

Profile
 
 
Posted: 28 November 2008 07:03 AM   [ Ignore ]   [ # 10 ]  
Research Scientist
Avatar
RankRankRankRankRankRank
Total Posts:  7061
Joined  04-15-2006

Hiya,

If you simply want a list of links then the quickest and most powerful way to achieve this is to create a weblog entry for each link. You will have your custom URL field called brandUrl which will hold the link as you have now.

In the template you would then just do this :

{exp:weblog:entries weblog="default_site"}
< a h*ef='{brandUrl}'>Whatever text I want…</a>
{/exp:weblog:entries}


Please change the link tag to look correct as the forums are stripping out code unfortunately

In the code example above where you have the Whatever text I want… you could also in each weblog entry have a custom field called linkText or something like that which would hold whatever you want the link to say. You would then just do this in your template :

{exp:weblog:entries weblog="default_site"}
< a h*ef='{brandUrl}'>{linkText}</a>
{/exp:weblog:entries}


Please change the link tag to look correct as the forums are stripping out code unfortunately

That should be it really. Can you provide a link to something that you have online so that we can see where you are having problems with this. Always helps to be working with an example.

One other thing you might want to check is in :

Admin->Weblog Administration->Weblog Management->Edit Preferences (Your Weblog Name)->Weblog Posting Preferences->Automatically turn URLs and email addresses into links?

You will want this to say No or you will get the links being created themselves and end up with very weird output on the page.

If we can get that part working for you first and then think about getting rid of the http bit afterwards which I think might cause a problem with the way that ExpressionEngine works but we can look at that later on, let’s just get links working for you first with whatever text you want.

Any of that help?

Best wishes,

Mark

 Signature 

Full List Of Plugins Here!! (16)
 
Retrieve Statuses
Maximum Posts Reached
Neat Link
Redirect
Fetch URI

Profile
 
 
Posted: 28 November 2008 07:03 AM   [ Ignore ]   [ # 11 ]  
Grad Student
Avatar
Rank
Total Posts:  77
Joined  06-27-2008
Beertastic - 28 November 2008 06:53 AM

Ah, still doesn’t work…
i’ve got several URLs in teh weblog..
fomatted
http://www.123.com

None of the above examples allow me to output:
<a href=“http://www.123.com”>MY CUSTOM TEXT</a>

that’s all I’m after..
No paths relative to teh CMS at all..
just external links..

well, I must have misunderstood you…
this is the most basic thing!

how did you set-up your weblog?
one entry per link?
if yes, you need to have a second custom field for the custom text! how else could your system know of that text…?

and if you have all the links in one entry… well… then…
use this:
<a href=“http://www.123.com”>MY CUSTOM TEXT</a>
wink

maybe someone else can help, cause I must be missunderstanding you completely… or maybe you post your code!
cheers

Profile
 
 
Posted: 28 November 2008 10:29 AM   [ Ignore ]   [ # 12 ]  
Grad Student
Avatar
Rank
Total Posts:  57
Joined  11-25-2008

I turned off auto link creation.. CHEERS!!
Perfect…


anyhoo, outline 4: I want to have different link text on the same links..
so perhaps in one instance, it’ll say ‘click here’ but another will say ‘visit site’
all on a per page basis…

if I create an extre field in my weblog, sure that’ll work, but only for one entry..
I need it to be more flaexible.. but I appreciate the thought…!

Tris..

Profile
 
 
Posted: 29 November 2008 02:11 PM   [ Ignore ]   [ # 13 ]  
Research Scientist
Avatar
RankRankRankRankRankRank
Total Posts:  7061
Joined  04-15-2006
Beertastic - 28 November 2008 10:29 AM

I turned off auto link creation.. CHEERS!!
Perfect…

Excellent news wink

Beertastic - 28 November 2008 10:29 AM

anyhoo, outline 4: I want to have different link text on the same links..
so perhaps in one instance, it’ll say ‘click here’ but another will say ‘visit site’
all on a per page basis…

if I create an extre field in my weblog, sure that’ll work, but only for one entry..
I need it to be more flaexible.. but I appreciate the thought…!

Tris..

When you say that you want different text for the links then what exactly will signify when the text should change. If we get a better idea of where or why you need to do this it might help out a bit more on this one. Also a link to the site or an example site that does this might also help.

Best wishes,

Mark

 Signature 

Full List Of Plugins Here!! (16)
 
Retrieve Statuses
Maximum Posts Reached
Neat Link
Redirect
Fetch URI

Profile
 
 
   
 
 
Post Marker Legend
New Topic New posts Hot Topic Hot Topic with new posts New Poll New Poll Moved Topic Moved Topic Sticky Topic Sticky topic
Old Topic No new posts Hot Old Topic Hot Topic with no new posts Old Poll Old Poll Closed Topic Closed Topic Announcement Announcements
Theme
Change Theme
Visitor Statistics
The most visitors ever was 1149, on July 16, 2007 09:33 AM
Total Registered Members: 66389 Total Logged-in Users: 40
Total Topics: 84714 Total Anonymous Users: 18
Total Replies: 454693 Total Guests: 197
Total Posts: 539407    
Members ( View Memberlist )