Copied to clipboard

Flag this post as spam?

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


  • George 12 posts 109 karma points
    Dec 06, 2014 @ 11:57
    George
    0

    Related Links Values

    Hi guys, im using razor macro engine to get the INTERNAL related links in a document.

    Is any way to get the values(properties + id) of these internal links?

    @inherits Umbraco.Web.Mvc.UmbracoTemplatePage

     

    @if(Model.Content.HasValue("selectRelatedLinks"))

    {

         @foreach (var item in CurrentPage.selectRelatedLinks)

             {

                                        var linkUrl = (item.Value<bool>("isInternal")) ? Umbraco.NiceUrl(item.Value<int>("internal")) : item.Value<string>("link");

                                        var linkTarget = item.Value<bool>("newWindow") ? "_blank" : null;

                      <span class="Internal LInks">

     <a href="@linkUrl" target="@linkTarget">

             <img alt="@(item.Value<string>("caption"))" class="img-responsive" src="@(item.IMAGE))">

    </a>

    </span>

     

          }

    }

     

    i want to bring the item image of each intnral link.

  • George 12 posts 109 karma points
    Dec 06, 2014 @ 21:02
    George
    101

    I ve got it. I give my code, if someone needs help with that.

                             @foreach (var item in CurrentPage.selectRelatedProducts)
                             {  
                                    var linkUrl = (item.Value<bool>("isInternal")) ? Umbraco.NiceUrl(item.Value<int>("internal")) : item.Value<string>("link");
                                    var linkTarget = item.Value<bool>("newWindow") ? "_blank" : null;
                                    var itemId= ((item.Value<bool>("isInternal")) ?  item.Value<int>("internal") : null);
                                    if(itemId != null)
                                    {
                                      Node myNode = new Node(itemId);
                                      string nodetitle = item.Value<string>("caption");
                                      if (myNode.GetProperty("producttitle") != null)
                                      {
                                          nodetitle = myNode.GetProperty("producttitle").Value;
                                      }
    
                                      var nodeimg = "/img/no_image.jpg";
    
                                      if (myNode.GetProperty("productimg") != null)
                                      {
                                            nodeimg = myNode.GetProperty("productimg").Value;
                                      }
    
    
                                      <li>
                                      <span>
                                      <a href="@linkUrl" target="@linkTarget">
                                                <span class="">
                                                    <span class="">
                                                        <span><i class=""></i> @umbraco.library.GetDictionaryItem("ProductPreview")</span>
                                                    </span>
                                                    <img alt="@(item.Value<string>("caption"))" class="img-responsive" src="@nodeimg">
                                                </span>
                                            </a>                                                        
                                            <span class="">
                                                <a href="@linkUrl" target="@linkTarget">
                                                    <h4>@nodetitle</h4>                                                 
                                                </a>
                                            </span>
                                      </li>
    
                                    }
    
                            }
    
Please Sign in or register to post replies

Write your reply to:

Draft