Custom Attribute that will display as hyperlink

Permalink 1 user found helpful
I need to add an attribute that when the users enters a url will on output to the page will be a hyperlink.

Is there a Custom Attribute type out there that would do this?

Thank you

cayercreative
 
glockops replied on at Permalink Best Answer Reply
glockops
You can do this with a text attribute. In a theme you can reference the attribute and spit out a hyperlink.

<?php
$myURL = $c->getAttribute('my_url_attribute');
echo '<a href="' . $myURL . '">' . $myURL . '</a>';
?>
cayercreative replied on at Permalink Reply
cayercreative
cool!

What would i do if i wanted to make the url appear as a button.

wrap it in a div and do image replacement?

<div class="bidbutton">

<?php
$myURL = $c->getAttribute('bid_url');
echo '<a href="' . $myURL . '">' . $myURL . '</a>'; ?>
</div


.bidbutton {
padding-top: 35px;
height: 0px;
overflow: hidden;
background-image: url(../images/bidbutton.gif);
background-repeat: no-repeat;
}
glockops replied on at Permalink Reply
glockops
Something like that would work - you could also just give the anchor tag a class.

Keep in mind that this will produce a link like:
<a href="http://google.com">http://google.com</a>

If you actually wanted words as a hyperlink you'll need to go a different route - either abandon the attribute idea and go with a block, add another attribute 'url-text' or something or use a non URL character to break the attribute into two portions and use PHP to split them.

Something like
My Link Text|http://google.com

You could read that in PHP, find the (|) and create two variables, load the one as the href and the other in between the <a></a> tags.

Keep the users of the system in mind - do whatever is going to be easiest for them to remember.
pakigreenl replied on at Permalink Reply
pakigreenl
Maybe you can help with my issue.
http://www.concrete5.org/community/forums/usage/create-user-attribu...

I can get the link to appear but it is not doing anything with the php. I want to link this code from the original members page:
<a href="<?php echo $this->url('/profile','view', $user->getUserID())?>"><?php echo $user->getUserName()?></a>

Do I need to pull more code from the members page and will it only work with html and not php?
pakigreenl replied on at Permalink Reply
pakigreenl
Maybe you can help with my issue.
http://www.concrete5.org/community/forums/usage/create-user-attribu...

I can get the link to appear but it is not doing anything with the php. I want to link this code from the original members page:
<a href="<?php echo $this->url('/profile','view', $user->getUserID())?>"><?php echo $user->getUserName()?></a>

Do I need to pull more code from the members page and will it only work with html and not php?
FatTony1952 replied on at Permalink Reply
FatTony1952
If there is no value for the link attribute you can use this that will only display the link space if it's filled in. That way you don't get any unnecessary spaces in your public view:

<? $someLinkableAttribute = $profile->getAttribute('some_linkable_attribute'); ?>
<? 
  if($someLinkableAttribute!=NULL){
  echo '<a href="'.$someLinkableAttribute.'">Link Text</a>' ;
    }
?>