Jump to:

17452 Posts in 4473 Topics by 1971 members

Archive

SilverStripe Forums » Archive » creating a hrdcoded image link with a feild

Our old forums are still available as a read-only archive.

Moderators: martimiz, Sean, biapar, Willr, Ingo, simon_w

Page: 1
Go to End
Author Topic: 903 Views
  • Pixel
    Avatar
    Community Member
    78 Posts

    creating a hrdcoded image link with a feild Link to this post

    I have two advert images on a website homepage which are displayed by two image uploaders and I have also created two text feilds where I want to put an external website address. Is it possible, within the homepage.ss to use the textfeilds to link the image? Here is what i have:

    <a href="http://$Left_Advert_Website">$Left_Advert</a>

    $Left_Advert_Website is the text feild for the site
    $Left_Advert is the image

    However when i hover over the image it displays" http:/// and on clicking I get the message: "The URL is not valid and cannot be loaded"

    Am i trying to do the impossible or is there anyway of resolving this issue - ideally i do not want to hard code the URL

  • Willr
    Avatar
    Forum Moderator
    5489 Posts

    Re: creating a hrdcoded image link with a feild Link to this post

    Yep it is certainly possible to do - $Left_Advert_Website probably hasnt been correctly saved. What you might have to do is wrap the variable in a {} to prevent it being interpreted as $Left_Advert_Website".. so you would have <a href="http://{$Left_Advert_Website}">. But first off you need to make sure Left_Advert_Website exists

  • Pixel
    Avatar
    Community Member
    78 Posts

    Re: creating a hrdcoded image link with a feild Link to this post

    OK im a noob!
    When creating the fields I first build the imagefeilds so that I could work on the visuals and get the page styling right. When it came to creating the textfeilds my natural instinct put them with the imagefeilds in the static $has_one = array rather than static $db = array. Whoops!

    Thanks for your help willr

    903 Views
Page: 1
Go to Top

Want to know more about the company that brought you SilverStripe? Then check out SilverStripe.com

Comments on this website? Please give feedback.