Copied to clipboard

Flag this post as spam?

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


  • Steve Brown 125 posts 290 karma points
    Sep 20, 2013 @ 21:07
    Steve Brown
    0

    publish date and remove date for media

    I want to insert links to media on a page, with publish dates and removal dates. What is the best way to accomplish this? I see this functionality exists out of the box for content nodes, is there some way to leverage that? Thanks for any guidance on this issue.

  • Ismail Mayat 4511 posts 10092 karma points MVP 2x admin c-trib
    Sep 23, 2013 @ 10:32
    Ismail Mayat
    0

    Steve,

    Not out of the box. When you say inert links do you mean in rich text editor? If NOT in rich text editor and they are properties eg media picker or multi node tree picker and you then you are writing out the links using a macro then you could put publish and remove date properties on media items and test for those dates in your macros when writing out the links.

    If in Richtext edit you could do something similar but it would be more work and you would need to write a http handler to do it.

    Regards

    Ismail

  • Steve Brown 125 posts 290 karma points
    Sep 23, 2013 @ 14:38
    Steve Brown
    0

    Ismail, thank you for the reply. To make sure I follow, I can add a couple properties to the media like "startDate" and "endDate" and write out the files with a macro? I will post back here with what I come up with in case it helps someone else.

  • Ismail Mayat 4511 posts 10092 karma points MVP 2x admin c-trib
    Sep 24, 2013 @ 17:19
    Ismail Mayat
    0

    Steve,

    That is correct. Like i said earlier this will only work if your writing out the images in a template or macro if the image is in via rich text edit field then this wont work you would need to write a httpmodule that uses those dates but it would be messy.

    Regards

    Ismail

  • Steve Brown 125 posts 290 karma points
    Sep 27, 2013 @ 14:54
    Steve Brown
    0

    Thanks for your help so far. I can't figure out how to access my custom media properties. I created two custom properties, their aliases are StartDate and EndDate.

    I want to add an If condition to only display those media items with a StartDate greater than or equal to today, or EndDate less than today, but I can't figure out how to access the properties. Here's my macro so far, which displays all the media items in the folder where I put them.

    @using umbraco.MacroEngines;
    @using umbraco.cms.businesslogic.media;
    @inherits Umbraco.Web.Macros.PartialViewMacroPage
    
    @{
    var mediaFolder = Umbraco.Media(1853);
    foreach(var jobPost in mediaFolder.Children())
    {
    <a href="@jobPost.umbracoFile">@jobPost.Name</a>
    }
    }
  • Ismail Mayat 4511 posts 10092 karma points MVP 2x admin c-trib
    Sep 27, 2013 @ 15:22
    Ismail Mayat
    100

    Steve,

    Try GetPropertyValue("StartDate") also i think do GetPropertyValue

    Regards

    Ismail

  • Steve Brown 125 posts 290 karma points
    Sep 27, 2013 @ 22:03
    Steve Brown
    0

    Excellent, that worked perfect! Thanks again for all your help.

  • Steve Brown 125 posts 290 karma points
    Oct 03, 2013 @ 21:07
    Steve Brown
    0

    Is there a way to order the media items? Currently it's displaying the oldest item at the top. I'd like to order by my property "StartDate" descending.

  • Steve Brown 125 posts 290 karma points
    Oct 03, 2013 @ 21:40
    Steve Brown
    0

    nevermind I figured it out. here is the line I had to change, in case it helps anyone

    foreach(var jobPost in mediaFolder.Children.OrderBy("startDate desc"))
Please Sign in or register to post replies

Write your reply to:

Draft