ASPX templates
Version 3.x > ASPX templates > Blog Posts View modes: 
User avatar
Member
Member
WE ARE VI - 9/24/2008 10:01:24 AM
   
Blog Posts
Hi,

In my default.aspx.cs Iam looping through blog posts so I can output the 4 latest blogs on the homepage. I currently have the following code output the title and the day:

int got = 0;
foreach (DataRow theRow in dataset.Tables[0].Rows)
{
listing += "<span class=\"blogDate\">" + theRow["BlogPostDate"] + "</span>\n";
listing += "<span class=\"blogTitle\">" + theRow["BlogPostTitle"] + "</span>\n";
got++;
if (got == 4) break;
}

BUT I also require hyperlinking the title to the rest of the post but do not know how to do this. Please help!

Thanks
James

User avatar
Kentico Support
Kentico Support
kentico_jurajo - 9/25/2008 3:12:21 AM
   
RE:Blog Posts
Hi,

Are you using ASPX or portal engine templates?

I think it will be easier to use repeater web part (or control). you can set the path to the blogs, also you can set "Select TOP N" items (in your case 4) and also ORDER BY expression and order the items by date, so only the top 4 are selected. Of course, you will need to use appropriate transformation to display the links to the blogs.

Best Regards,
Juraj Ondrus

User avatar
Member
Member
WE ARE VI - 9/25/2008 3:32:06 AM
   
RE:Blog Posts
I am a complete newbie to kentico and very intermediate to C#. Please could you explain further what I need to do ?

Thank you in advance.
James

User avatar
Member
Member
WE ARE VI - 9/25/2008 4:15:20 AM
   
RE:Blog Posts
We are using ASPX. Inside the "CMSTemplates" directory I have default.aspx that has:

<asp:Label ID="plcRecentBlogs" runat="server" Text=""></asp:Label>

and in the default.aspx.cs I have the loop above and at the end:

plcRecentBlogs.Text = listing;

Any help will be greatly appreciated!
Thanks,
James Mitchell

User avatar
Kentico Support
Kentico Support
kentico_jurajo - 9/25/2008 4:23:00 AM
   
RE:Blog Posts
Hi James,

I would like to recommend you to go through our ASPX tutorial to see how the web site is developed - http://devnet.kentico.com/downloads/KenticoCMS_Tutorial_aspx.pdf

You only need to open appropriate page tempalte (.aspx) on which you want to display the blogs. Add/Register there the repeater control and configure its properties (path, class names, where condition, transformation) - http://devnet.kentico.com/docs/controls/cmsrepeater.htm

I hope it will help.

Best Regards,
Juraj Ondrus