Close

Blog Landing Page with Excerpts only

bsgcraft
10 years ago
#4369 Quote
Avatar
  • 49
I saw a theme by another developer who shows on their demo site the blog landing page as an excerpt type format. See here:  http://noplite-demo.pronopcommerce.com/blog

Is there a way to achieve this with this theme? I want a way to condense the entries on the main blog page with the "read more" link to go to the actual entry.

Thanks in advance!
Nate Kindom
YashChandra
10 years ago
#4381 Quote
Avatar
  • Moderator
  • 62
Hi,

This is quite easy to do in the Blog\List.cshtml view. On line 46:

@Html.Raw(item.Body) you can truncate the item.Body to as many characters as you need and format it as you need. Below it you can add a link to the blog post. So the code could be something like:

@Html.Raw(item.Body.Substring(0, 300) + "...")
<br/>
<a class="post-title" href="@Url.RouteUrl("BlogPost", new { SeName = item.SeName })">@item.Title</a>


I hope this is useful!
Regards,
Milen Kovachev
Nop-Templates.com
bsgcraft
10 years ago
#4385 Quote
Avatar
  • 49
What about the issue of having some entries having images first? The snipit of code would also include those as characters as well. Is there a way to code it so it ignores the img tag altogether within the content body and apply the character count that way?
Nate Kindom
YashChandra
10 years ago
#4388 Quote
Avatar
  • Moderator
  • 62
You can parse the item.Body beforehand for all <img ... tags via Regex and replace it with String.Empty.
Regards,
Milen Kovachev
Nop-Templates.com