This project is read-only.

widget: how to get info about post (if it's permalink etc.)?

Topics: Controls
Nov 15, 2011 at 3:10 PM


I'd like to create a widget that will show something depending what kind of page the user is browsing.

E.g. if not permalink (e.g. home, searchresults, or month): show some generic info.

If permalink: show info about the author.

I'm a newbie and I wonder how to access the information of the page/context. The only thing that comes to my mind is checking the url.

a permalink begins with "/post". ... maybe there is a better way? thx

Nov 15, 2011 at 3:53 PM
Edited Nov 15, 2011 at 4:08 PM

I check the "id" querystring to see if it has a value. Even if there is no id in the users browser, the url gets rewritten at the server so that any page/post being viewed has an id querystring. This will give you the ID of the page/post which you can use to get info about it.

You can use BlogEngiine.Core.Page. and BlogEngine.Core.Post to get info about the page/post using the ID.

Nov 16, 2011 at 7:53 AM

You can just check the URL

If URL contains /post   then its a post

If URL contains /page then its a page

If URL contains anything else then its a page thats in the root like contact and etc.

Thats all that you need to do.

You can even go with specific pages or posts just put in the URL thats needed.

Keep us updated on your widget :)

I am interested in it too!

Have a good day,

Brian Davis