I’m working on a project to make the archive section of the
website change the way it displays.
I have converted the links to collate how many posts there are
for a set date and to display the number in brackets.
What I’m trying to achieve now is to make the link for the date
not display the newest post, but to show a list with the title and summary for
each post for that date.
Now i have made a new if statement in
"uBlogsyListPost.cshtml" to display the page how i want. But in the
"uBlogsyListPostArchive.cshtml" file I have no idea how to make the
link, link to say /news/posts/2014/june/ and then for that to link through to
my new if statement in uBlogsyListPost template.
I do hope this makes sense and someone could help.
Thank for this code to make the link go to /news/posts/2014/june/ for example.
But when i go to that url it shows the last post from that month. How do i make it use my new tample layout where it will show a list of pages like the example link i gave before? I cant work out how to get the URL to know to use a different template. I see in the templates there is a Small="0" which means it will show the whole post or Small="1" which will show a list like Latest post does. But how do i make these links use a Small="2" for example which displays a list with titles and Summaries?
you can probably just change the allowed templates of the month doctype to use the ublogsy landing template.
And add this to the macroscript
else if (@Parameter.Small == "2")
{
IEnumerable<DynamicNode> posts = Model.DescendantsOrSelf("uBlogsyPost");
var postCount = posts.Count();
// show each post
foreach (DynamicNode n in nodes)
{
@RenderPage("/macroScripts/uBlogsy/uBlogsyShowPost.cshtml", n.Id)
} }
How would uBlogsy know to use that when you click a link which looks like "/news/posts/2014/june/" that it doesnt go to the last post of that month but instead go to our new parameter of Small="2" and display it that way?
Just incase anyone wants to see how i got this to work. This is the code for the page uBlogsyListPostArchive.cshtml. I then created a new template dedicated for the MonthFolder to change the look and feel of what would be shown.
@for (int j = DateTime.Now.Year; j >= (DateTime.Now.Year - 5); j--)
{
string yearClass = "uBlogsy_year";
var allpostforyearnumber = (from p in nodes
where p.GetPropertyValue("uBlogsyPostDate") != String.Empty &&
DateTime.Parse(p.GetPropertyValue("uBlogsyPostDate")).Year == j
select p.GetPropertyValue("uBlogsyPostDate")).ToList();
if (allpostforyearnumber.Count > 0)
{
// render years-months-items
<li class="@yearClass">
<a class="uBlogsy_year_name second-level-link" href="#">@j.ToString()</a> @*render year name*@
<ul class="uBlogsy_months nav-drop-level-2">
@{
//Loop around each month in a year
for (int i = 12; i >= 1; i--)
{
//Get article count for that month
var allpostformonthnumber = (from p in nodes
where p.GetPropertyValue("uBlogsyPostDate") != String.Empty &&
DateTime.Parse(p.GetPropertyValue("uBlogsyPostDate")).Month == i &&
DateTime.Parse(p.GetPropertyValue("uBlogsyPostDate")).Year == j
select p.GetPropertyValue("uBlogsyPostDate")).ToList();
//If greater than zero show list item and display count
if (allpostformonthnumber.Count > 0)
{
var urlText = CultureInfo.CurrentCulture.DateTimeFormat.GetMonthName(i) + " (" + allpostformonthnumber.Count.ToString() + ")";
var monthLink = "/news/posts/" + j.ToString() + "/" + CultureInfo.CurrentCulture.DateTimeFormat.GetMonthName(i);
<li class="uBlogsy_month">
<a class="uBlogsy_month_name third-level-link" href="@monthLink">@urlText</a>@*render month name*@
</li>
}
}
}
</ul>
</li>
}
}
Modify Archive URL
Hello,
I’m working on a project to make the archive section of the website change the way it displays.
I have converted the links to collate how many posts there are for a set date and to display the number in brackets.
What I’m trying to achieve now is to make the link for the date not display the newest post, but to show a list with the title and summary for each post for that date.
Now i have made a new if statement in "uBlogsyListPost.cshtml" to display the page how i want. But in the "uBlogsyListPostArchive.cshtml" file I have no idea how to make the link, link to say /news/posts/2014/june/ and then for that to link through to my new if statement in uBlogsyListPost template.
I do hope this makes sense and someone could help.
Thank you
So you want the archive to NOT show the actual articles.
You want the month links to go to /news/posts/2014/june/
Is that correct?
I would like it to display like this: http://www.beattiegroup.com/aboutour-pragency/prnews-m04-y2014.aspx
on this website you can see that April has 2 posts. when you click the April button on the left, it displays the title and summary of those 2 posts.
You basically want this:
Thank for this code to make the link go to /news/posts/2014/june/ for example.
But when i go to that url it shows the last post from that month. How do i make it use my new tample layout where it will show a list of pages like the example link i gave before? I cant work out how to get the URL to know to use a different template. I see in the templates there is a Small="0" which means it will show the whole post or Small="1" which will show a list like Latest post does. But how do i make these links use a Small="2" for example which displays a list with titles and Summaries?
you can probably just change the allowed templates of the month doctype to use the ublogsy landing template.
And add this to the macroscript
How would uBlogsy know to use that when you click a link which looks like "/news/posts/2014/june/" that it doesnt go to the last post of that month but instead go to our new parameter of Small="2" and display it that way?
You need to change the template in the backoffice for the folder doctypes to just use the landing page template.
of course. Thank you so much.
Just incase anyone wants to see how i got this to work. This is the code for the page uBlogsyListPostArchive.cshtml. I then created a new template dedicated for the MonthFolder to change the look and feel of what would be shown.
is working on a reply...