Forum Discussion

kiettuongwork's avatar
kiettuongwork
Contributor
7 years ago

How to retrive info from query string and pass into component in Lithium

Hi Support Team,

 

I have tried to check how component in Lithium queries data for 4 pages above.

There is an issue need to get advise from Lithium support.

Scenario:

Once we access URL as below 

We want to get last part of URL in this case is "Reviews" and then pass that parameter to component name "recent-blog-posts"

And in component we will get parameter by using code as below

<#assign category = http.request.parameters.name.get("category", "") />

Question: 

  1. Where should check that component is used in admin of Lithium?
  2. How can we parse parameter from URL after /bg-p and then pass that parameter to component recent-blog-posts?
    1. 11112222
    2. Reviews
    3. LetsInspire
    4. NewAtDigi

Thanks,

Mickey

13 Replies

  • syafiq's avatar
    syafiq
    Ace
    7 years ago
    please try it in the page where you use this component. it should be working in the blog page.

    https://xxxxxxxxx/t5/blogname/bg-p/blogname
  • kiettuongwork's avatar
    kiettuongwork
    Contributor
    7 years ago

    Hi,

    Actually I dun know how to pass that URL in the page that using the post component.

    May you please show me how to do that?

     

    Thanks,

    Mickey

  • SuzieH's avatar
    SuzieH
    Khoros Alumni (Retired)
    7 years ago

    Hi kiettuongwork,

    What are you trying to do with your recent-blog-posts component? What is the component's purpose? Is there a reason why you are choosing to pass these blogs by parsing the URL instead of using a call to the Community API via the rest FreeMarker context object? I'm wondering if there is an easier way to accomplish your task. 

     

    Have you seen either of these TKB articles?

    Building your first custom component - Note this article uses Community API v1

    Update a component from API v1 to v2