Copied to clipboard

Flag this post as spam?

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


  • Aaron Barboza 4 posts 74 karma points
    Jul 28, 2018 @ 01:19
    Aaron Barboza
    0

    How can I get the main image from for example NuevaNoticia.cshtml to Noticias.cshtml

    Hi!

    I'm just new in umbraco 7, I have a issue and need understanding how to get an image url from another page, not the current page. I have a string variable working normally in the page NuevaNoticia.cshtml as bellow:

    string principalImageUrl = "";
    if (Model.Content.HasValue("imagenPrincipal"))
    {
        principalImageUrl = Model.Content.GetPropertyValue<IPublishedContent>("imagenPrincipal").Url;
    }
    

    So I use the @principalImageUrl to call the image and is working properly, but how can I call the image to the Noticias.cshtml?

    I'm using a @foreach to set the new "NuevaNoticia" in the "Noticias" page, the only thing is broken is the image in the Noticias.cshtml.

    Another question related:

    And how can I make like just to show 4 items in the Noticias.cshtml with the option of selecting the page number with the same number of items and the prev and last buttons?

    Help!

    Thanks!

  • Aaron Barboza 4 posts 74 karma points
    Jul 28, 2018 @ 07:59
    Aaron Barboza
    0

    Hi!

    I already solved!

    For the image issue:

    <img src="@Umbraco.Media(item.GetPropertyValue("mainImage").ToString()).Url?anchor=center&mode=crop&w=400&h=275" />

    And for the pagination question I get this example :

    A quick & easy razor pagination to plug into an Umbraco View, Partial View, or Macro. From a GitHub Contributor

Please Sign in or register to post replies

Write your reply to:

Draft