I'm working with articulate for the first time, and I'm trying to display posts from the blog on my homepage.
My homepage template contains the following
@Html.Partial("/views/partials/displayblogitemsonhomepage.cshtml", new Articulate.Models.ListModel(Umbraco.Content(1368)))
and my partial view is as follows
using Articulate
@using Articulate.Models
@using Umbraco.Core
@using Umbraco.Web
@model Articulate.Models.ListModel
@{
Layout = null;
}
<h3>Recent News</h3>
@if (!Model.Children.Any()) //getting object ref not found error here
{
<p>No blog posts found</p>
}
else
{
@foreach (var post in Model.Children<PostModel>())
{
//show posts
}
}
however it's giving me object reference not found errors. The Node Id I'm passing is the node for the archive section of the articulate blog in the backend, clearly this isn't the way to do it!
but the stack trace error says "No overload for method 'ToString' takes 1 arguments." @post.CreateDate.ToString("MMMM dd, yyyy") works great. Do I need to cast or access the property a little differently? Thanks in advance!
Phillip, you are trying to apply the date formatting to an object, not a DateTime type. You will need to cast the object as a DateTime object first, before executing the method ToString("MMMM dd, yyyy). Cheers.
I followed the above notes and am getting the following exception
The best overloaded method match for 'Articulate.Models.ListModel.ListModel(Umbraco.Core.Models.IPublishedContent)' has some invalid arguments
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Could it be related to the node you're pulling back as the root for the articulate blog? I've noticed that the logical node to pull back would be the main blog node, but actually if you're pulling stuff through to the homepage you're better off using the archive node instead.
EDIT: Removed my code as I realised it was the same stuff I posted above.
I did get it working by passing in the correct id, however i did find some odd behavior.
In my view i was using var root = Model.AncestorOrSelf(1); > When using this and stepping through the code, it would throw a null exception unless i stepped through very slow. I replaced with var root = Model.RootBlogNode; to avoid this problem
What makes it odd is that the AncestorOrSelf approach would NOT WORK if i ran the site without debugging. Slowing it down however allowed Model.AncestorOrSelf(1) to resolve itself to something other than null.
Hi,
Just got this working and pulling a list of recent blog posts through to my homepage but I was wonder. Is there a way to pull 2 archives in to one feed?
Just now I have a partial view and then use two Html.Partial calls on my template.
@Html.Partial("umbLatestBlogWidget", new Articulate.Models.ListModel(Umbraco.Content(1298)))
@Html.Partial("umbLatestBlogWidget", new Articulate.Models.ListModel(Umbraco.Content(1312)))
This then gives me two separate lists.
I guess I need to somehow read the two lists and then merge them together in date order but I have no idea where to start with that.
You can union the two lists together, then load the partial view.
For example, save the lists into variables first, then perform a union on the list and pass that to the partial view. The union will remove any duplicate entries.
var list1 = new Articulate.Models.ListModel(Umbraco.Content(1298));
var list2 = new Articulate.Models.ListModel(Umbraco.Content(1312));
Of course! Stupid me. Still learning Umbraco & Razor, as if you couldn't notice :)
The next issue is Articulate doesn't have a definition for Union. For something that should be straight forward it's causing many issues or the lack of my own understanding is probably causing a lot of issues!
Compiler Error Message: CS1061: 'Articulate.Models.ListModel' does not contain a definition for 'Union' and no extension method 'Union' accepting a first argument of type 'Articulate.Models.ListModel' could be found (are you missing a using directive or an assembly reference?)
Apologies, I hadn't test the above. The ListModel cannot have union applied to it as it's not a list, it's a model that contains a list as well as other properties.
To do the union you will need to do something like this:
@{
var list1 = new Articulate.Models.ListModel(Umbraco.Content(1298)).Children();
var list2 = new Articulate.Models.ListModel(Umbraco.Content(1312)).Children();
}
@Html.Partial("umbLatestBlogWidget", list1.Union(list2))
However now the type has changed in the partial. Therefore the model in the partial will need to be changed to:
@model IEnumerable<IPublishedContent>
If you do wish to access any of the ListModel properties within the partial, you still can by accessing the parent.
E.g.
@foreach (var item in Model)
{
var parent = item.Parent as ListModel;
}
Sorry, this is just not working for me. I wish I could even troubleshoot rather than constantly relying on your good efforts.
My master page has:
@{
var list1 = new Articulate.Models.ListModel(Umbraco.Content(1298)).Children();
var list2 = new Articulate.Models.ListModel(Umbraco.Content(1312)).Children();
}
@Html.Partial("umbLatestBlogWidget", list1.Union(list2));
My partial looks like this:
@using Articulate
@using Articulate.Models
@using Umbraco.Core
@using Umbraco.Web
@inherits Umbraco.Web.Mvc.UmbracoViewPage<Articulate.Models.ListModel>
@{
var root = Model.AncestorOrSelf(3);
var blogRoot = root.Children;
var blogArchive = root.Children.First();
if (!blogArchive.Children.Any())
{
<p>No blog posts found</p>
}
else
{
string strLastClass = "";
<ul class="recent_blogs">
@foreach (var post in blogArchive.Children.OrderByDescending(b => b.GetPropertyValue("publishedDate")).Take(3))
{
if (post.IsLast())
{
strLastClass = "last";
}
<h4>Blogs</h4>
<li class="@strLastClass">
<h5><a href="@post.Url">@post.Name</a></h5>
<p>@post.GetPropertyValue("Excerpt")</p>@post.GetPropertyValue("publishedDate")
</li>
}
</ul>
}
}
I tried changing the inherits to model but I still get horrible errors.
Just now the error I get on the first var list1 = new ...... is
System.NullReferenceException: Object reference not set to an instance of an object.
This will break your partial because you are still trying to deal with a ListModel in the code. Therefore if you need to use ListModel properties you will need to get the parent of a list item first, then perform the rest of your code on that
E.g.
@{
var parentItem = Model.FirstOrDefault().Parent as ListModel;
var root = parentItem.AncestorOrSelf(3);
var blogRoot = root.Children;
var blogArchive = root.Children.First();
...
}
Thanks!
I think I've got it almost there with your help but I'm just not getting this last bit.
I've changed the inherits in my partial to what you suggest, I've change the parentItem etc. But the line with
var list1 = new Articulate.Models.ListModel(Umbraco.Content(1297)).Children();
Is throwing an error due to it returning a Null.
I've finally got it building in VisualStudio rather than trying to just to it within Umbraco and it build fine with no errors.
If list1 is null, it means that either content item 1297 doesn't exist, it is not a ListModel, or it has no children (blog posts). Ensure that all the above are satisfied and it should work.
For error proofing, you could check for null values first before trying to get the children.
Content item 1297 exists because it was pulling the blog posts through when I was doing one blog, one list. It has blog posts in it so what it looks like is it's not a ListModel - how would I check / fix this if that is the case?
I really appreciate the help but I'm still stuck trying to pull two blog streams together so that it shows them in one list on my homepage.
Is anyone else able to help me please.
I've been trying to get this to work for the past couple of days, I thought I had cracked it but I'm still getting the error:
An exception of type 'System.NullReferenceException' occurred in Articulate.dll but was not handled in user code
Additional information: Object reference not set to an instance of an object.
Now, if I use the number 1289 or 1312 to display the one blog, it pulls the posts with no issues so I know that this is working but I also know that I am obviously not understanding how this works from all the help I've been given so far.
My masterpage has:
<div class="col-md-4">
@{
var list1 = new Articulate.Models.ListModel(Umbraco.Content(1289)).Children();
var list2 = new Articulate.Models.ListModel(Umbraco.Content(1312)).Children();
list1.ToList();
list2.ToList();
}
@Html.Partial("umbLatestBlogWidget", list1.Union(list2));
</div>
my Partial has:
@using Articulate
@using Articulate.Models
@using Umbraco.Core
@using Umbraco.Web
@inherits Umbraco.Web.Mvc.UmbracoViewPage<IEnumerable<IPublishedContent>>
@{
var parentItem = Model.FirstOrDefault().Parent as ListModel;
var root = parentItem.AncestorOrSelf(3);
var blogRoot = root.Children;
var blogArchive = root.Children.First();
//var root = Model.AncestorOrSelf(3);
//var blogRoot = root.Children;
//var blogArchive = root.Children.First();
if (!blogArchive.Children.Any())
{
<p>No blog posts found</p>
}
else
{
string strLastClass = "";
<ul class="recent_blogs">
@foreach (var post in blogArchive.Children.OrderByDescending(b => b.GetPropertyValue("publishedDate")).Take(3))
{
if (post.IsLast())
{
strLastClass = "last";
}
<li class="@strLastClass">
<h5><a href="@post.Url">@post.Name</a></h5>
<p>@post.GetPropertyValue("Excerpt")</p>@post.GetPropertyValue("publishedDate")
</li>
}
</ul>
}
}
I found a checkbox within the document type for the articulate archive which wasn't ticked - "enable list view" I clicked it and hoped this would solve the issue, but nope, I still being told
var list1 = new Articulate.Models.ListModel(Umbraco.Content(1289)).Children();
is returning a null value, i've changed the node number to see if that helps but nothing.
Hi Bobi,
This is how I've done it - my homepage pulls in posts from two different authors but you may be able to work with my code and get yours working.
Ok, so I tried the same code as your partial in my partial, and then tried to call it. Everything is running, except whatever is supposed to show up from your partial isn't ... ?
Ok, this make a bit more sense then why you are having issues.
What I would do is allow Articulate to be a child of the index document type.
Click on Index then on the Properties tab on the right hand side, click the Document Type. Once that loads, click on Permissions up in the top right hand corner. Then click the Add Child button and add Articulate. Save.
Once you have done this, right click on the Articles link under content which you have shown in your screenshot. Click Move in the sub menu and select your Index page. This should move your Articles under Index.
That should hopefully help get everything showing like I have it :)
Thank you so much, your code works! This is brilliant! Thank you so much! I have only a few strands of hair left after pulling it all out over frustration over this. Thanks Owain!
You wouldn't happen to know a way to implement a full site search would you? I have a search for the blog, but am thinking of implementing a full site search.
Thanks Owain. I used the simple one too...It works great. I'm trying to figure out how to display an excerpt (some text in front and behind of the search term query, so that it can be called and displayed underneath the @result.Name; and then ideally, to highlight the search text by bolding it. Any knowledge as to how to go about that?
I tried the advanced tutorial too, but unfortunately, my site does not use field properties, so it's not too effective, since the advanced tute relies on those fields.
Thanks again Owain. Good-luck with the new project.
Would you know how to manipulate the code you provided (for the displaying of recent posts on homepage) to do the same thing, but instead only show posts in certain categories or in certain tags?
What I've managed to do is pull from a tag by changing the initial lookup:
var blogNodes = @Model.Content.AncestorOrSelf(1).Descendants("ArticulateRichText").OrderBy("publishedDate desc").Take(6).Where("tags.Contains(\"running\")");
You will see I've added a Where clause. There is one error that I've found though. If there is a list of tags e.g. running, training, somethingelse - it will display the running blog perfectly, however, if running is not first, e.g. training, running, somethingelse, the blog isn't displayed.
To fix this I think you'd need to pull the tags and maybe iterate through a loop check each tag. I'll see if I can get time to test this and use it as my next blog post on my new umbraco site :) www.wildsitecreations.co.uk
I was hoping something like this would work but I get an error:
var blogNodes = @Model.Content.AncestorOrSelf(1).Descendants("ArticulateRichText").Where("tags.Split(',').Contains(\"running\")").OrderBy("publishedDate desc").Take(6);
Maybe someone else will be able to say where I'm going wrong.
Error: Umbraco.Core.Dynamics.ParseException: No applicable method 'Split' exists in type 'String'
That's brilliant. I'm noticing the same issue where only one blog post is being pulled with the specified tag or category, even if "running" is first in another post.
After some help from Kris Janssen (another helpful member) and a bit of tinkering, I ended up with the following, which works to filter by category. I hope this helps you make your method above work, since I like the simplistic nature of it. If you figure it out, feel free to let me know :)
@inherits UmbracoTemplatePage
@{
// EDIT: This node id is unlikely to ever change so hardcoding it should be OK.
var newsroot = Umbraco.TypedContent(1066);
var blogArchive = newsroot.Children.First();
var categories = Umbraco.TagQuery
.GetAllContentTags("ArticulateCategories")
.Select(x => x.Text)
.OrderBy(x => x);
var categoriesUrl = newsroot.GetPropertyValue<string>("categoriesUrlName");
// EDIT: Get the Children here once instead of repeatedly
var entries = blogArchive.Children();
var postDate = newsroot.CreateDate.ToString("MMMM d, yyyy");
string c = "Test";
}
<!--=== News Block ===-->
<div class="bg-grey">
<div class="container content-sm">
<div class="text-center margin-bottom-50">
<h2 class="title-v2 title-center">RECENT NEWS</h2>
</div>
<div class="row news-v1">
@if (c == "Test")
{
var filteredEntries = entries
// EDIT: Splitting the property value is not needed ...
.Where(x => x.GetPropertyValue<string>("categories") != null && x.GetPropertyValue<string>("categories").InvariantContains(c))
//EDIT: Only order after selecting for the categories, less to order that way
.OrderByDescending(x => x.UpdateDate)
.Take(3)
.ToList();
foreach (var p in filteredEntries)
{
var blogTitle = @p.Name;
<div class="col-md-4 md-margin-bottom-40">
<div class="news-v1-in bg-color-white">
<a href="@(newsroot.Url + "/" + categoriesUrl + "/" + c)"><img class="img-responsive" src="@p.GetCropUrl("postImage", "indexBlogPost")" title="@p" alt="@p" /></a>
<h3 class="font-normal"><a href="@(newsroot.Url + "/" + categoriesUrl + "/" + c)">@blogTitle</a></h3>
<p>@(Umbraco.Truncate(p.GetPropertyValue<string>("excerpt"), 75))</p>
<ul class="list-inline news-v1-info no-margin-bottom">
<li><i class="fa fa-clock-o"></i> @postDate</li>
</ul>
</div>
</div>
}
}
@*else if (c != "Test")
{
<div class="col-md-4 md-margin-bottom-40">
<div class="news-v1-in bg-color-white">
<h3>No News</h3>
</div>
</div>
}
*@
</div>
</div>
</div>
<!--=== End News Block ===-->
It works, which is nice. I am just trying to figure out how to now display some generic html code (i.e. No recent news) if there are no articles in the specified category.
Edit
I got things working. There may be inefficiencies, but nevertheless here it is:
@using Articulate
@using Articulate.Models
@using System.Linq
@inherits UmbracoTemplatePage
@{
// EDIT: This node id is unlikely to ever change so hardcoding it should be OK.
var newsroot = Umbraco.TypedContent(1066);
var blogArchive = newsroot.Children.First();
var categories = Umbraco.TagQuery
.GetAllContentTags("ArticulateCategories")
.Select(x => x.Text)
.OrderBy(x => x);
var categoriesUrl = newsroot.GetPropertyValue<string>("categoriesUrlName");
// EDIT: Get the Children here once instead of repeatedly
var entries = blogArchive.Children();
var filteredEntries = entries
// EDIT: Splitting the property value is not needed ...
.Where(x => x.GetPropertyValue<string>("categories") != null && x.GetPropertyValue<string>("categories").InvariantContains("Test"))
//EDIT: Only order after selecting for the categories, less to order that way
.OrderByDescending(x => x.CreateDate)
.Take(3)
.ToList();
}
<!--=== News Block ===-->
<div class="bg-grey">
<div class="container content-sm">
<div class="text-center margin-bottom-50">
<h2 class="title-v2 title-center">RECENT NEWS</h2>
</div>
<div class="row news-v1">
@if (filteredEntries == null || filteredEntries.Count() == 0)
{
<div class="md-margin-bottom-40 text-center">
<h3 class="font-normal">No Recent News</h3>
</div>
}
else
{
foreach (var blogNode in filteredEntries)
{
var blogTitle = @blogNode.Name;
var tempExcerpt = @blogNode.GetPropertyValue("excerpt").ToString();
var postDate = blogNode.CreateDate.ToString("MMMM d, yyyy");
const int MaxLength = 133;
<div class="col-md-4 md-margin-bottom-40">
<div class="news-v1-in bg-color-white">
<a href="@blogNode.Url"><img class="img-responsive" src="@blogNode.GetCropUrl("postImage", "indexBlogPost")" title="@blogTitle" alt="@blogTitle" /></a>
<h3 class="font-normal"><a href="@blogNode.Url">@blogTitle</a></h3>
@if (tempExcerpt.Length > MaxLength)
{
tempExcerpt = tempExcerpt.Substring(0, MaxLength) + "...";
}
<p>@tempExcerpt</p>
<ul class="list-inline news-v1-info no-margin-bottom">
<li><i class="fa fa-clock-o"></i> @postDate</li>
</ul>
</div>
</div>
}
}
</div>
</div>
</div>
<!--=== End News Block ===-->
I am playing around with the idea of changing my node structure due to Articulate's longer than desired url when Articulate is added as a child to your homepage.
I'm trying to avoid the dreaded url example.com/articulate/archive/first-post for obvious SEO reasons. As well there are duplicate pages when it comes to example.com/articulate and example.com/articulate/archive.
As such, I'm looking to structure the site like so (second scenario):
As you can see the Articulate node is at the root, along with Homepage.
However, changing this mucks things up when it comes to pulling in recent posts to Homepage. Currently, I'm using the following to pull in recent blog posts:
var blogNodes = @Model.Content.AncestorOrSelf(1).Descendants("ArticulateRichText").OrderBy("publishedDate desc").Take(4);
This works great for the first scenario, but not in the second updated node structure.
How can a modify the above code to work in the second scenario?
Displaying Articulate blog posts on my homepage
Hi All
I'm working with articulate for the first time, and I'm trying to display posts from the blog on my homepage.
My homepage template contains the following
and my partial view is as follows
however it's giving me object reference not found errors. The Node Id I'm passing is the node for the archive section of the articulate blog in the backend, clearly this isn't the way to do it!
Can anyone point me in the right direction?
Cheers
Shaun
Shaun, not sure if this is the way to go, however this is the approach I am taking...
var root = CurrentPage.AncestorOrSelf(1);
var blogHome = root.Children.Single(x => x.DocumentTypeAlias == "Articulate");
var blogArchive = blogHome.Children.Single(x => x.DocumentTypeAlias == "ArticulateArchive");
ListModel lModel = new ListModel(blogArchive, blogArchive.Children(),
new PagerModel(blogArchive.Children().Count(), 1, blogArchive.Children().Count()/10));
Not sure about the PagerModel issue, I am using the lModel variable to call:
Umbraco.GetRecentPosts(lModel, 5)
Would love to know if there is a better way of doing this.
Russell
Cheers Russell!
I couldn't quite get your code to work,but it did lead me to this solution. Thanks again!
Below is my new partial view, it's being called by the same html.partial statement as the one above
Anybody have luck with manipulating articleDate into a different format? I have something like
foreach (var post in blogArchive.Children.OrderByDescending(b => b.GetPropertyValue("publishedDate")).Take(3))
{
<li class="@(post.IsLast() ? " last" : "" )">
<span>@post.GetProperty("publishedDate").ToString("MMMM dd, yyyy")</span>
</li>
}
but the stack trace error says "No overload for method 'ToString' takes 1 arguments." @post.CreateDate.ToString("MMMM dd, yyyy") works great. Do I need to cast or access the property a little differently? Thanks in advance!
Phillip, you are trying to apply the date formatting to an object, not a DateTime type. You will need to cast the object as a DateTime object first, before executing the method ToString("MMMM dd, yyyy). Cheers.
I followed the above notes and am getting the following exception
The best overloaded method match for 'Articulate.Models.ListModel.ListModel(Umbraco.Core.Models.IPublishedContent)' has some invalid arguments
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Any ideas as to how to resolve? I am new to Umbraco and don't quite understand the integration between articulate and umbraco. See also this post https://our.umbraco.org/forum/umbraco-as-a-service/general-questions/64222-Umbraco-7-plus-Articulate-blog-engine
Hi Dave
Could it be related to the node you're pulling back as the root for the articulate blog? I've noticed that the logical node to pull back would be the main blog node, but actually if you're pulling stuff through to the homepage you're better off using the archive node instead.
EDIT: Removed my code as I realised it was the same stuff I posted above.
I did get it working by passing in the correct id, however i did find some odd behavior.
In my view i was using var root = Model.AncestorOrSelf(1); > When using this and stepping through the code, it would throw a null exception unless i stepped through very slow. I replaced with var root = Model.RootBlogNode; to avoid this problem
What makes it odd is that the AncestorOrSelf approach would NOT WORK if i ran the site without debugging. Slowing it down however allowed Model.AncestorOrSelf(1) to resolve itself to something other than null.
I can't explain this.
Hi, Just got this working and pulling a list of recent blog posts through to my homepage but I was wonder. Is there a way to pull 2 archives in to one feed? Just now I have a partial view and then use two Html.Partial calls on my template.
This then gives me two separate lists.
I guess I need to somehow read the two lists and then merge them together in date order but I have no idea where to start with that.
Hi Owain,
You can union the two lists together, then load the partial view.
For example, save the lists into variables first, then perform a union on the list and pass that to the partial view. The union will remove any duplicate entries.
var list1 = new Articulate.Models.ListModel(Umbraco.Content(1298));
var list2 = new Articulate.Models.ListModel(Umbraco.Content(1312));
@Html.Partial("umbLatestBlogWidget", list1.Union(list2))
Hope this helps.
Nathan
Thanks for the speedy reply Nathan! I gave your solution a go but I get an error saying
Which is the link the @Html.Partial is on.
Hi Owian,
You will need to use razor syntax to use the variables. Try:
E.g.
@{
var list1 = new Articulate.Models.ListModel(Umbraco.Content(1298));
var list2 = new Articulate.Models.ListModel(Umbraco.Content(1312));
}
@Html.Partial("umbLatestBlogWidget", list1.Union(list2))
Cheers
Of course! Stupid me. Still learning Umbraco & Razor, as if you couldn't notice :)
The next issue is Articulate doesn't have a definition for Union. For something that should be straight forward it's causing many issues or the lack of my own understanding is probably causing a lot of issues!
Apologies, I hadn't test the above. The ListModel cannot have union applied to it as it's not a list, it's a model that contains a list as well as other properties.
To do the union you will need to do something like this:
However now the type has changed in the partial. Therefore the model in the partial will need to be changed to:
If you do wish to access any of the ListModel properties within the partial, you still can by accessing the parent.
E.g.
Sorry, this is just not working for me. I wish I could even troubleshoot rather than constantly relying on your good efforts.
My master page has:
My partial looks like this:
I tried changing the inherits to model but I still get horrible errors.
Just now the error I get on the first var list1 = new ...... is
System.NullReferenceException: Object reference not set to an instance of an object.
You will need to change the @inherits to accept an IEnumerable
E.g.
This will break your partial because you are still trying to deal with a ListModel in the code. Therefore if you need to use ListModel properties you will need to get the parent of a list item first, then perform the rest of your code on that
E.g.
Thanks! I think I've got it almost there with your help but I'm just not getting this last bit. I've changed the inherits in my partial to what you suggest, I've change the parentItem etc. But the line with
Is throwing an error due to it returning a Null.
I've finally got it building in VisualStudio rather than trying to just to it within Umbraco and it build fine with no errors.
OK it sounds like you have made some progress.
If list1 is null, it means that either content item 1297 doesn't exist, it is not a ListModel, or it has no children (blog posts). Ensure that all the above are satisfied and it should work.
For error proofing, you could check for null values first before trying to get the children.
Content item 1297 exists because it was pulling the blog posts through when I was doing one blog, one list. It has blog posts in it so what it looks like is it's not a ListModel - how would I check / fix this if that is the case?
Cheers.
I really appreciate the help but I'm still stuck trying to pull two blog streams together so that it shows them in one list on my homepage. Is anyone else able to help me please.
Thanks in advance.
I've been trying to get this to work for the past couple of days, I thought I had cracked it but I'm still getting the error:
Now, if I use the number 1289 or 1312 to display the one blog, it pulls the posts with no issues so I know that this is working but I also know that I am obviously not understanding how this works from all the help I've been given so far.
My masterpage has:
my Partial has:
Can anyone tell me where my mistake is please....
I found a checkbox within the document type for the articulate archive which wasn't ticked - "enable list view" I clicked it and hoped this would solve the issue, but nope, I still being told
is returning a null value, i've changed the node number to see if that helps but nothing.
Hi,
I have a question that seems to be driving me mad. How can I pull a partial view into my home page simple? I just want to reference:
@Html.ThemedPartial(Model, "Latest")
from Articulate blog. However, I am not sure how to do this because I do not know what using directives to include, etc.?
Hi Bobi, This is how I've done it - my homepage pulls in posts from two different authors but you may be able to work with my code and get yours working.
My partial looks like this:
Then I on my homepage template I just use:
umbLatestBlogWidget is the name of my partial.
Hope that helps.
You can see how this looks on my website www.runningbeside.me
Thanks so much Owain,
I will try it out and let you know. What do your using directives and @inherits look like on your homepage?
Homepage:
That's it. :)
Thanks so much. I will try it out and let you know. I'm assuming your partial is stored in App_Plugins/Articulate/Themes/"Theme Name"/Views/Partials.
Hi Bobi, No my partial is kept within root/views/partials not within Articulate itself.
I set it up via the backoffice just in the usual partials folder 'settings/patrialviews/'
Ok, so I tried the same code as your partial in my partial, and then tried to call it. Everything is running, except whatever is supposed to show up from your partial isn't ... ?
Hi, Here is how I have articulate setup in the backoffice:
So I have a doctype called Blog Pages which I then nest Articulate within. You may need to change
Change the (1) to another number, if you have your Articulate blog sitting under the root, maybe change the 1 to a 0.
Hi, thanks again for following-up. You've been extremely helpful in what I can only describe as one of the most frustrating of things...
My content appears as so:
index is my supposed to be my homepage...
Ok, this make a bit more sense then why you are having issues.
What I would do is allow Articulate to be a child of the index document type.
Click on Index then on the Properties tab on the right hand side, click the Document Type. Once that loads, click on Permissions up in the top right hand corner. Then click the Add Child button and add Articulate. Save.
Once you have done this, right click on the Articles link under content which you have shown in your screenshot. Click Move in the sub menu and select your Index page. This should move your Articles under Index.
That should hopefully help get everything showing like I have it :)
Thank you so much, your code works! This is brilliant! Thank you so much! I have only a few strands of hair left after pulling it all out over frustration over this. Thanks Owain!
PS. I checked out your blog; looks awesome.
Glad I could help. I've had so much help on here that it's nice that I can actually help someone else for a change :)
O.
You wouldn't happen to know a way to implement a full site search would you? I have a search for the blog, but am thinking of implementing a full site search.
Hi, Yip, I followed these tutorials :
https://www.youtube.com/watch?v=b5wbazkehH8
or
advanced search: https://www.youtube.com/watch?v=b5wbazkehH8
I've also got a thread on here talking about implementing a fuzzy search but I've not had a chance to try out the code.
Thanks Owain. I used the simple one too...It works great. I'm trying to figure out how to display an excerpt (some text in front and behind of the search term query, so that it can be called and displayed underneath the @result.Name; and then ideally, to highlight the search text by bolding it. Any knowledge as to how to go about that?
I tried the advanced tutorial too, but unfortunately, my site does not use field properties, so it's not too effective, since the advanced tute relies on those fields.
I've not had a chance to work with the search stuff much yet. Been busy on a separate project but I'll give you a shout if I do get back on it soon :)
Thanks again Owain. Good-luck with the new project.
Would you know how to manipulate the code you provided (for the displaying of recent posts on homepage) to do the same thing, but instead only show posts in certain categories or in certain tags?
Hi Bobi, I had a quick play with this last night.
What I've managed to do is pull from a tag by changing the initial lookup:
You will see I've added a Where clause. There is one error that I've found though. If there is a list of tags e.g. running, training, somethingelse - it will display the running blog perfectly, however, if running is not first, e.g. training, running, somethingelse, the blog isn't displayed.
To fix this I think you'd need to pull the tags and maybe iterate through a loop check each tag. I'll see if I can get time to test this and use it as my next blog post on my new umbraco site :) www.wildsitecreations.co.uk
Let me know if you manage to get it to work.
I was hoping something like this would work but I get an error:
Maybe someone else will be able to say where I'm going wrong.
Error: Umbraco.Core.Dynamics.ParseException: No applicable method 'Split' exists in type 'String'
That's brilliant. I'm noticing the same issue where only one blog post is being pulled with the specified tag or category, even if "running" is first in another post.
Owain,
After some help from Kris Janssen (another helpful member) and a bit of tinkering, I ended up with the following, which works to filter by category. I hope this helps you make your method above work, since I like the simplistic nature of it. If you figure it out, feel free to let me know :)
It works, which is nice. I am just trying to figure out how to now display some generic html code (i.e. No recent news) if there are no articles in the specified category.
Edit
I got things working. There may be inefficiencies, but nevertheless here it is:
Great work! :) Glad you got it working.
O.
Hi all,
I am playing around with the idea of changing my node structure due to Articulate's longer than desired url when Articulate is added as a child to your homepage.
Currently my site structure is (first scenario):
I'm trying to avoid the dreaded url example.com/articulate/archive/first-post for obvious SEO reasons. As well there are duplicate pages when it comes to example.com/articulate and example.com/articulate/archive.
As such, I'm looking to structure the site like so (second scenario):
As you can see the Articulate node is at the root, along with Homepage.
However, changing this mucks things up when it comes to pulling in recent posts to Homepage. Currently, I'm using the following to pull in recent blog posts:
This works great for the first scenario, but not in the second updated node structure.
How can a modify the above code to work in the second scenario?
is working on a reply...