Portal Engine Questions on portal engine and web parts.
Version 5.x > Portal Engine > Acessing latest blogs through jQuery View modes: 
User avatar
Member
Member
andrew-gradweb.co - 2/9/2012 5:34:04 AM
   
Acessing latest blogs through jQuery
Hi,

I have been making a number of changes to my website (some of which this forum has very kindly helped me with) but I have one final item remaining.

If possible I would like to be able to get a list of the latest blog posts and links to the blogs through jQuery which I can then display on the front page. I am relatively new to jQuery and am reading up on it right now but any pointers or hints would be greatly appreciated.

I am aware this is not directly a Kentico issue but I would like to know if it is possible to do this?

Kind Regards,

Andrew

User avatar
Member
Member
kentico_michal - 2/12/2012 2:41:15 AM
   
RE:Acessing latest blogs through jQuery
Hello,

I am not completely sure what you would like to achieve, so, could you please describe your request in more detail.

jQuery as a javascript library can be primarily used to get and change elements in the rendered HTML content.

I will give you simple example that you can use to create a link that allows users to hide and display div that contains all latest blogs posts. To display the latest posts you can use the repeater with a correct Where condition. Then, you need to set the Content after/before properties of the Repeater web part as shown here:

Content Before: <div id="latestBlogs" class="classDisableBlogs" >
Content After: </div>

The CSS styles definition for the classDisableBlogs class can look like the following one:

.classDisableBlogs{ display:none; }

This simply disables that latest blog posts after the page is displayed.

However, you can add the following jQuery code along with the link to the page:

<script type="text/javascript">
$(document).ready(function(){
$(".lnkDisplayBlogs").click(function(event) {
event.preventDefault();
$("#latestBlogs").toggleClass("classDisableBlogs");
})
})
</script>

<a class="lnkDisplayBlogs" href=""> Display latest blog posts </a>


As a result, after the link has been clicked, the CSS class classDisableBlogs is removed and the div with all blog posts is displayed.

Best regards,
Michal Legen