Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Katelynne Rosera 15 posts 85 karma points
    Aug 25, 2015 @ 16:34
    Katelynne Rosera
    0

    Generic Properties

    Hello!

    Can anyone help me with this: I am trying to get an image to link to an external website. I have the generic property set up at a textstring but what Razor code do I need in the template to get the image to link to the external webpage?

  • James 251 posts 1169 karma points
    Aug 25, 2015 @ 20:56
    James
    0

    Hello there,

    It depends if you want the image source to be from another website or whether you want to link to another site.

    If you want the source to be another site try:

    <img src="@Umbraco.Field("TextstringPropertyAlias")" alt=""/>
    

    Or if you want to link to an external site:

    <a href="@Umbraco.Field("TextStringPropertyAlias")">
         <img src="" alt=""/>
    </a>
    

    You can also use the following:

    @CurrentPage.TextStringPropertyAlias

    Hope this helps Cheers

  • Katelynne Rosera 15 posts 85 karma points
    Aug 25, 2015 @ 21:12
    Katelynne Rosera
    0

    I want to have the image that we upload to go to another website that isn't within our Umbraco page. I had originally set up as a content picker, but that was for things within our website.

    I realized that I needed a textstring to be able to have a link elsewhere.

    I tried all 3 options, and they didn't work. Here is what I have:

    @inherits Umbraco.Web.Mvc.UmbracoTemplatePage @{ Layout = "MasterPage.cshtml"; var slide = CurrentPage; }

    @CurrentPage.TextStringPropertyAlias@slide.header

  • James 251 posts 1169 karma points
    Aug 26, 2015 @ 10:49
  • Katelynne Rosera 15 posts 85 karma points
    Aug 26, 2015 @ 13:02
    Katelynne Rosera
    0

    So what if I want the link to be different each time? What razor syntax code do I use in the the href="@...?"

  • James 251 posts 1169 karma points
    Aug 26, 2015 @ 14:04
    James
    0

    You would use:

    <a href="@CurrentPage.ExternalHyperLink">
    </a>
    

    It will automatically pick up the property value for the page it is on. So if one page has one value and the other has another value, then they will be different.

    E.g. Page 1 has http://google.com Page 2 has http://yahoo.com

    Page 1 would look like this once loaded:

    <a href="http://google.com">
    </a>
    

    and Page 2 would look like this once loaded:

    <a href="http://yahoo.com">
    <a/>
    

    I hope this helps :)

  • Katelynne Rosera 15 posts 85 karma points
    Aug 26, 2015 @ 14:17
    Katelynne Rosera
    0

    So, in the Doc Type, do I need to call it "External HyperLink"?

  • Katelynne Rosera 15 posts 85 karma points
    Aug 26, 2015 @ 14:25
    Katelynne Rosera
    0

    It's still not working. This is what I have.

    @inherits Umbraco.Web.Mvc.UmbracoTemplatePage @{Layout = "MasterPage.cshtml"; var slide = CurrentPage;}
    <section id="home-slider"><div class="container">
    <a href="@CurrentPage.ExternalHyperLink"><img data-src="@slide.GetCropUrl(propertyAlias:"image", cropAlias:"Banner")" src="@slide.GetCropUrl(propertyAlias:"image", cropAlias:"Banner")" alt="@slide.header" class="img-responsive" /></a>
      </div>
            </section>
    

    enter image description here

  • Chris 92 posts 238 karma points
    Aug 26, 2015 @ 14:50
    Chris
    0

    Hey Katelynne,

    can you look into your log file and copy the error you get?

  • Katelynne Rosera 15 posts 85 karma points
    Aug 26, 2015 @ 15:02
    Katelynne Rosera
    0

    I don't get an error - it just isn't pulling the hyperlink. It's pulling the page link that it's already on!

  • James 251 posts 1169 karma points
    Aug 26, 2015 @ 22:17
    James
    0

    Hello,

    You can name the property whatever you like but it must exist on any document type that uses that template which you are calling it .

    Hope this helps

  • Chris 92 posts 238 karma points
    Aug 27, 2015 @ 06:37
    Chris
    0

    Don't know if I unterstand the problem correct:

    You want to add a external link to a page, but when you add a textstring propertie with a link you still get the umbraco-page's url?

    Example: When on page "http://this-is-my-umbraco.com", you create there a external link to "google.com" your URL looks like "http://this-is-my-umbraco.com/google.com" ?

    If this is the problem: Just add a "Http://" before your link. So in my example "http://www.google.com" and the anker works.

    If this is not the problem, can you post a screenshot of how your anker/href-attribute looks like?

  • Katelynne Rosera 15 posts 85 karma points
    Aug 27, 2015 @ 13:16
    Katelynne Rosera
    0

    The problem is I am trying to get an image to link to "external-website.com" but instead the image is linking to "this-is-my-umbraco.com".

  • Chris 92 posts 238 karma points
    Aug 27, 2015 @ 13:33
    Chris
    0

    Can you give me an example what value you type into your "ExternalHyperLink" field?

  • Katelynne Rosera 15 posts 85 karma points
    Aug 27, 2015 @ 13:36
    Katelynne Rosera
    0

    Can you please elaborate on that? What do you mean by "value"?

  • Chris 92 posts 238 karma points
    Aug 27, 2015 @ 13:42
    Chris
    0

    When you edit your Content Node in the backoffice, what is the text you enter in your "ExternalHyperLink" propertie?

    See picture: enter image description here

  • Katelynne Rosera 15 posts 85 karma points
    Aug 27, 2015 @ 13:56
    Katelynne Rosera
    0

    enter image description here

  • Chris 92 posts 238 karma points
    Aug 27, 2015 @ 14:14
    Chris
    0

    Sadly I really can't tell what the problem is. Do you have the property on the right template?

    On your ContentNode "Test", of which you made a screenshot, there is a tab "Properties" and below that a dropdown menu for "Template". The chosen template is the same template you added the @CurrentPage.ExternalHyperLink property?

    And can you try to change your code to:

        <section id="home-slider">
          <div class="container">
            <a href="@Umbraco.Field("ExternalHyperLink")">
               <img data-src="@slide.GetCropUrl(propertyAlias:"image", cropAlias:"Banner")" src="@slide.GetCropUrl(propertyAlias:"image", cropAlias:"Banner")" alt="@slide.header" class="img-responsive" />
            </a>
          </div>
        </section>
    
  • Katelynne Rosera 15 posts 85 karma points
    Aug 27, 2015 @ 14:30
    Katelynne Rosera
    0

    I put in that code...still isn't working :(

  • Chris 92 posts 238 karma points
    Aug 27, 2015 @ 14:39
    Chris
    0

    Did you check if the right template is used?

    Don't think I can help you here without having a look into your umbraco installation (teamviewer or skype). But I'm going home in 20 Minutes and won't come back to work for a week. (Will check this thread when I have time)

    Maybe someone else is willing to help you through skype or teamviewer.

  • James 251 posts 1169 karma points
    Aug 27, 2015 @ 15:18
    James
    0

    If you need me to help you I can over Skype james.cull1990

    Can you confirm that your "External Banner Image Link" has a property alias of "externalHyperLink"?

    Try @Umbraco.Field("ExternalBannerImageLink")

    This may work :)

    Or: @CurrentPage.ExternalBannerImageLink

    Hope this helps! :)

  • Katelynne Rosera 15 posts 85 karma points
    Aug 27, 2015 @ 15:34
    Katelynne Rosera
    0

    I can confirm that the property alias is externalHyperLink

    I tried @Umbraco.Field("ExternalHyperLink"); @Umbraco.Field("ExternalBannerImageLink"; and @CurrentPage.ExternalBannerImageLink - didn't work.

    Still keeps linking to the current page and not the external link. I didn't build this, I'm just editing the code. I'm not sure what is overriding this code :(

  • James 251 posts 1169 karma points
    Aug 28, 2015 @ 09:31
  • James 251 posts 1169 karma points
    Aug 28, 2015 @ 09:41
    James
    0

    Also could you show us the code you have in the view?

  • Bjarne Fyrstenborg 1280 posts 3990 karma points MVP 7x c-trib
    Aug 28, 2015 @ 10:42
    Bjarne Fyrstenborg
    0

    Hi Katelynne

    I would also recommend you to take a look at the package UrlPicker. Then the editors decide whether the link should be internal or external - so they have both the option to pick content nodes, media nodes, enter a external link or link to an uploaded file (not in media section). You can configurate the datatype to use all four types or only some of them.

    For external links you can of course just use a textstring datatype, but if you both need to link internal and external, I think UrlPicker is a great choice :)

    Here is an example of how to get its content: https://gist.github.com/kgiszewski/9842878

    /Bjarne

  • Katelynne Rosera 15 posts 85 karma points
    Aug 28, 2015 @ 14:10
    Katelynne Rosera
    0

    enter image description here

  • Katelynne Rosera 15 posts 85 karma points
    Aug 28, 2015 @ 14:11
Please Sign in or register to post replies

Write your reply to:

Draft