Forum Discussion

wpigoury's avatar
wpigoury
Mentor
12 years ago

Getting current label within a component

Hi,

 

Is there a way to get the current label from within a component?

I mean another way than to parse the url and retrieve the label-name value from it.

 

There should be something in the request parameter or attributes but I can't put my finger on it.

 

I created a little component listing the labels used in my Ideas section in tabs and when I clicked on a label I would like to highlight the corresponding tab and to keep it highlighted as long as I browse ideas with this label.

 

Thanks.

    • Inactive User's avatar
      Inactive User

      I'm working on something similar. Unfortunately, that call seems to be returning "lithium.eval.velocity.TextLabelTemplateModel@285012ef". Any idea why this would happen? Thanks.

      • AdamN's avatar
        AdamN
        Khoros Oracle

        Inactive User This is happening because that method "returns a wrapped version of an object created from the specified path parameter". So in this particular case, you're actually getting an object corresponding to the label, rather than just the text of the label itself. That's why in my sample code above, after I assign the result to "label", I'm using "label.text" to print out the actual name of the label.

    • wpigoury's avatar
      wpigoury
      Mentor

      It worked for me, thanks.

       

      My last problem now is to display the labels in the order they have been set in the admin and not by alphabetical order.

       

      Any idea?

  • Nevermind I found the solution for my last problem.

    Instead of /labels I use /labels/predefined which gives me the labels in the exact order they appear in the admin.