Copied to clipboard

Flag this post as spam?

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


  • Andrea 24 posts 44 karma points
    Jan 12, 2011 @ 10:17
    Andrea
    0

    Newbie - C# Get last published contents by document type

    Hi all,

    I'm a umbraco newbie and I want some info.

    What I would like to do:

    In the site I'll publish legal news and I want to send to site's members the list of published news of the last week. Obviosly I'll send one mail per week.

    I made the registration member following the istruction given by Tim Geysens on his blog. On the same blog I found the Mail Engine Package but I want to send the emails automatically.

    To do these I need to create a specific user control and a scheduled task to hit a specific page URL that contain a custom user control.

    Using the umbraco api and c# How can I get the list of the published news week and get for each news the title (a defined property) and the news url??

    What I want to know (Using umbraco api and c#):

    1. Get the list of published contents by Document Type and filter the data by date

    2. Get the list of active members with email and some defined properties data.

    To hit a specific page URL is not a problem. My web hosting provider has a specific tool to do these.

     

    Thanks

  • Dirk De Grave 4541 posts 6021 karma points MVP 3x admin c-trib
    Jan 12, 2011 @ 10:42
    Dirk De Grave
    0

    Hi Andrea,

     

    Here's some ideas to get you started:

    Get list of published content:

    - Linq2umbraco if you're on a v4.5+ install and query the published xml for specified content (ie News) and filter by date. Find some examples on @slace's blog

    - Iterate the published content starting (probably starting from a specific node) using the Node class, for example:

    var node = new Node(startingNodeId);
    var newsNodes = node.Children;
    foreach (Node newsNode in newsNodes) {}

    - Query the published content using xpath expression. You can use the umbraco library function GetXmlContentByXPath() which returns a XPathNodeIterator which you can use to iterate.

    Get list of active members

    - Either use the member api (not recommended as doing quite some sql queries for a large member base) or use the Membership api (preferred and standard .net way)

     

    Hope this helps.

    Regards,

    /Dirk

  • Hendy Racher 863 posts 3849 karma points MVP 2x admin c-trib
    Jan 12, 2011 @ 11:03
    Hendy Racher
    1

    Hi Andrea,

    There's also a helper class called uQuery in the uComponents project that may be useful.eg.

    To get a list of all nodes by document type:

    List<Node> nodes = uQuery.GetNodesByType("doctypeAlias");

    To get all members with a particular property set:

    List<Member> members = uQuery.GetMembersByXPath("descendant::*[child::propertyAlias = 'propertyValue']");

    To get a property value for a member:

    string propertyValue = member.GetProperty<string>("propertyAlias");

    HTH,

    Hendy

  • Andrea 24 posts 44 karma points
    Jan 13, 2011 @ 10:14
    Andrea
    0

    Hi thanks for the info.

    Using Linq and Membership I've create the newsletter system.

    There is only one problem. The sended email contains the list of news with the link but the link is wrong. In used the follow code

    umbraco.

    library.NiceUrl(news.Id)

    and the url generated is http://content+page+name/

     

    Where is the error???

  • Dirk De Grave 4541 posts 6021 karma points MVP 3x admin c-trib
    Jan 13, 2011 @ 17:22
    Dirk De Grave
    0

    Depends on your umbracoSettings.config configuration. Did you set useDomainPrefixes to true? If not, please do so and NiceUrl() will include the hostname (assuming you've also set the hostname on a top level node within your content structure

    May need to republish your documents so your urls will include the hostname

    Hope this helps.

    Regards,

    /Dirk

  • Andrea 24 posts 44 karma points
    Jan 14, 2011 @ 10:12
    Andrea
    0

    Thanks Dirk.

Please Sign in or register to post replies

Write your reply to:

Draft