Forum Discussion

nickyates's avatar
nickyates
Mentor
12 years ago

Linking blog archive dates to a custom blog

Hi,

 

I have created an entirely custom blog page which works great however i would like to intergrate archives into this.  Currently when i click on an archives date range it links me back to my blog page but i have not written any code to extract the date section from the URL e.g. /t5/Sports-blog/bg-p/sports_blog/date/4-21-2013

 

Is there any way i can get this date information so i can add the date range to my api call on the blog page?  I have read the threads below but it doesnt quite answer my question.

 

 

https://lithosphere.lithium.com/t5/developers-discussion/Date-filtering-on-REST-topic-retrieval/m-p/17890/highlight/true#M1467

 

Thanks

 

Nick

  • I would also suggest customizing the BlogMessage page instead of the BlogPage.  In the BlogPage you have a component called

     

    <component id="articles"/>

     

    This component is made up of individual article messages.  Each one of those is a BlogMessage.  If you keep "aritcles" in place and change BlogMessage you will get paging, label filters, and archives without having to do any customization.  You can, of course, customize the BlogPage around that "articles" component as much as you like.  Here is an example of what your xml would look like:

     

    BlogPage

    <?xml version="1.0" encoding="UTF-8"?>
    <quilt layout="two-column.main-side" nestable="false">
      <add to="common-header">
        <component id="quilt:Header"/>
      </add>
      <add to="main-content">
        <component id="menu-bar"/>
        <component id="archive-info"/>
        <component id="filtered-by"/>
        <component id="articles"/>
        <component id="paging"/>
      </add>
      <add to="side-content">
        <component id="twitter.widget.stream"/>
        <component id="kudos.widget.messages-leaderboard"/>
        <component id="blogs.widget.bios"/>
        <component id="common.widget.announcement"/>
        <component id="blogs.widget.labels"/>
        <component id="blogs.widget.archives"/>
        <component id="forums.widget.polls"/>
        <component id="kudos.widget.givers-leaderboard"/>
      </add>
    </quilt>

     

    BlogMessage

    <?xml version="1.0" encoding="UTF-8"?>
    <quilt layout="blog-message">
    	<add to="main">
    		<component id="my-custom-blog-article" />
    	</add>
    	<add to="footer-left">
    		<component id="actions" />
    		<component id="modbar" />
    	</add>
    	<add to="footer-right">
    		<component id="kudos" />
    		<component id="bookmarks" />
    	</add>
    </quilt>

     

    The only thing to keep in mind is that BlogMessage is used both on the BlogPage and on the BlogArticlePage.  So when you are writing your custom component you will likely need some code that change the output depeding on the page. For example, in my "my-custom-blog-article" component I would have:

     

    <#if page.name =="BlogPage">
    show custom stuff on the blog page (teasers and things)
    <#else>
    <#-- show the normal stuff -->
    		<@component id="message-header" />
    		<@component id="body" />
    		<@component id="message-footer" />
    </#if>

     

2 Replies

  • AdamN's avatar
    AdamN
    Khoros Oracle
    12 years ago

    You may be able to use the webuisupport context object, specifically the path.parameters.name.get(...) methods, though I'm not sure how well it will work with a custom page.

    http://lithosphere.lithium.com/t5/developers-knowledge-base/Context-objects-for-custom-components-webuisupport/ta-p/9343

     

    If nothing else, you could use the http.request context object to get the request url (http.request.url) and then parse it youself using FreeMarker.

    http://lithosphere.lithium.com/t5/developers-knowledge-base/Context-objects-for-custom-components-http-request/ta-p/9323

     

    Here's a snippet I've used before for parsing out the message id from a URL. It should be pretty straight-forward to adapt it for your needs to get the "date" path parameter instead:

    <#function getUrlPathParameter url param >
         <#assign urlWithoutQs = url?split("?")?first />
         <#assign urlParameters = urlWithoutQs?split("/") />
         <#assign value = "" />
         <#list urlParameters as key>
               <#if key = param && key_has_next>
                    <#assign value = urlParameters[key_index + 1] />
               </#if>
         </#list>
         <#return value>
    </#function>    
    You're replying to message: ${getUrlPathParameter(http.request.url,"message-id")}
    

     

    I hope this helps!

  • KaelaC's avatar
    KaelaC
    Lithium Alumni (Retired)
    12 years ago

    I would also suggest customizing the BlogMessage page instead of the BlogPage.  In the BlogPage you have a component called

     

    <component id="articles"/>

     

    This component is made up of individual article messages.  Each one of those is a BlogMessage.  If you keep "aritcles" in place and change BlogMessage you will get paging, label filters, and archives without having to do any customization.  You can, of course, customize the BlogPage around that "articles" component as much as you like.  Here is an example of what your xml would look like:

     

    BlogPage

    <?xml version="1.0" encoding="UTF-8"?>
    <quilt layout="two-column.main-side" nestable="false">
      <add to="common-header">
        <component id="quilt:Header"/>
      </add>
      <add to="main-content">
        <component id="menu-bar"/>
        <component id="archive-info"/>
        <component id="filtered-by"/>
        <component id="articles"/>
        <component id="paging"/>
      </add>
      <add to="side-content">
        <component id="twitter.widget.stream"/>
        <component id="kudos.widget.messages-leaderboard"/>
        <component id="blogs.widget.bios"/>
        <component id="common.widget.announcement"/>
        <component id="blogs.widget.labels"/>
        <component id="blogs.widget.archives"/>
        <component id="forums.widget.polls"/>
        <component id="kudos.widget.givers-leaderboard"/>
      </add>
    </quilt>

     

    BlogMessage

    <?xml version="1.0" encoding="UTF-8"?>
    <quilt layout="blog-message">
    	<add to="main">
    		<component id="my-custom-blog-article" />
    	</add>
    	<add to="footer-left">
    		<component id="actions" />
    		<component id="modbar" />
    	</add>
    	<add to="footer-right">
    		<component id="kudos" />
    		<component id="bookmarks" />
    	</add>
    </quilt>

     

    The only thing to keep in mind is that BlogMessage is used both on the BlogPage and on the BlogArticlePage.  So when you are writing your custom component you will likely need some code that change the output depeding on the page. For example, in my "my-custom-blog-article" component I would have:

     

    <#if page.name =="BlogPage">
    show custom stuff on the blog page (teasers and things)
    <#else>
    <#-- show the normal stuff -->
    		<@component id="message-header" />
    		<@component id="body" />
    		<@component id="message-footer" />
    </#if>