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.
- 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)
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
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
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:
- 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
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:
To get all members with a particular property set:
To get a property value for a member:
HTH,
Hendy
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???
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
Thanks Dirk.
is working on a reply...