how to get category name through plugin?

classic Classic list List threaded Threaded
6 messages Options
Reply | Threaded
Open this post in threaded view
|

how to get category name through plugin?

aric.t.tan
Hello all,


I am trying to get selected category names for the plugin I am currently working on..

What I have right now is the Contentlet object:
Contentlet tmpCon = conList.get(0);

I know for a fact that inside of that Contentlet, there is velocity variable "groupCategory" but when I call:
String grp = tmpCon.getStringProperty("groupCategory"); //this returns null, even though the Contentlet I used for testing has groupCategory filled from the front end

Then I tried:
tmpCon.getCategoryId();
I got some UUID back but I think this is not what I am looking for.


So I tried to list all Categories in the database by:
List<Category> list = APILocator.getCategoryAPI().findAll(user, true);
for(Category c : list) {
  System.out.println(c.getCategoryId() + " "  + c.getCategoryName());
}
I can see all category, both the parents and children.

Taking one of the id shown there, I tried:
String catid = "9d2ea265-ca72-4ab5-90a5-c67c9a36a6b0";
cat = catAPI.find(catid, user, true);
Now this category is returning category name that I need...


The question is, how do I connect Contentlet that I have to this Category API?


Thank you in advance.


Regards,


Aric

--
You received this message because you are subscribed to the Google Groups "dotCMS User Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
Visit this group at http://groups.google.com/group/dotcms.
For more options, visit https://groups.google.com/groups/opt_out.
Reply | Threaded
Open this post in threaded view
|

Re: how to get category name through plugin?

Falzone, Chris
I haven't ported my code that does this to 2.5 yet, but the following is how I did it in 1.9.  I don't assume it has changed:

Set<Category> currentSelectedCategories = (Set<Category>) conAPI.getFieldValue(theContentlet, theStructure.getFieldVar("categoryFieldVarName"));



On Fri, Jan 31, 2014 at 11:46 AM, <[hidden email]> wrote:
Hello all,


I am trying to get selected category names for the plugin I am currently working on..

What I have right now is the Contentlet object:
Contentlet tmpCon = conList.get(0);

I know for a fact that inside of that Contentlet, there is velocity variable "groupCategory" but when I call:
String grp = tmpCon.getStringProperty("groupCategory"); //this returns null, even though the Contentlet I used for testing has groupCategory filled from the front end

Then I tried:
tmpCon.getCategoryId();
I got some UUID back but I think this is not what I am looking for.


So I tried to list all Categories in the database by:
List<Category> list = APILocator.getCategoryAPI().findAll(user, true);
for(Category c : list) {
  System.out.println(c.getCategoryId() + " "  + c.getCategoryName());
}
I can see all category, both the parents and children.

Taking one of the id shown there, I tried:
String catid = "9d2ea265-ca72-4ab5-90a5-c67c9a36a6b0";
cat = catAPI.find(catid, user, true);
Now this category is returning category name that I need...


The question is, how do I connect Contentlet that I have to this Category API?


Thank you in advance.


Regards,


Aric

--
You received this message because you are subscribed to the Google Groups "dotCMS User Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
Visit this group at http://groups.google.com/group/dotcms.
For more options, visit https://groups.google.com/groups/opt_out.



--

Christopher Falzone

Interactive Developer


A Q U E N T

Digital, Creative, and Marketing Talent


aquent.com

[hidden email]

--
You received this message because you are subscribed to the Google Groups "dotCMS User Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
Visit this group at http://groups.google.com/group/dotcms.
For more options, visit https://groups.google.com/groups/opt_out.
Reply | Threaded
Open this post in threaded view
|

Re: how to get category name through plugin?

Falzone, Chris


On Fri, Jan 31, 2014 at 11:58 AM, Falzone, Chris <[hidden email]> wrote:
I haven't ported my code that does this to 2.5 yet, but the following is how I did it in 1.9.  I don't assume it has changed:

Set<Category> currentSelectedCategories = (Set<Category>) conAPI.getFieldValue(theContentlet, theStructure.getFieldVar("categoryFieldVarName"));



On Fri, Jan 31, 2014 at 11:46 AM, <[hidden email]> wrote:
Hello all,


I am trying to get selected category names for the plugin I am currently working on..

What I have right now is the Contentlet object:
Contentlet tmpCon = conList.get(0);

I know for a fact that inside of that Contentlet, there is velocity variable "groupCategory" but when I call:
String grp = tmpCon.getStringProperty("groupCategory"); //this returns null, even though the Contentlet I used for testing has groupCategory filled from the front end

Then I tried:
tmpCon.getCategoryId();
I got some UUID back but I think this is not what I am looking for.


So I tried to list all Categories in the database by:
List<Category> list = APILocator.getCategoryAPI().findAll(user, true);
for(Category c : list) {
  System.out.println(c.getCategoryId() + " "  + c.getCategoryName());
}
I can see all category, both the parents and children.

Taking one of the id shown there, I tried:
String catid = "9d2ea265-ca72-4ab5-90a5-c67c9a36a6b0";
cat = catAPI.find(catid, user, true);
Now this category is returning category name that I need...


The question is, how do I connect Contentlet that I have to this Category API?


Thank you in advance.


Regards,


Aric

--
You received this message because you are subscribed to the Google Groups "dotCMS User Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
Visit this group at http://groups.google.com/group/dotcms.
For more options, visit https://groups.google.com/groups/opt_out.



--

Christopher Falzone

Interactive Developer


A Q U E N T

Digital, Creative, and Marketing Talent


aquent.com

[hidden email]




--

Christopher Falzone

Interactive Developer


A Q U E N T

Digital, Creative, and Marketing Talent


aquent.com

[hidden email]

--
You received this message because you are subscribed to the Google Groups "dotCMS User Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
Visit this group at http://groups.google.com/group/dotcms.
For more options, visit https://groups.google.com/groups/opt_out.
Reply | Threaded
Open this post in threaded view
|

Re: how to get category name through plugin?

aric.t.tan
In reply to this post by Falzone, Chris
Thank you very much, Chris!

It does work in 2.5.2!



On Friday, 31 January 2014 11:58:39 UTC-5, Chris Falzone wrote:
I haven't ported my code that does this to 2.5 yet, but the following is how I did it in 1.9.  I don't assume it has changed:

Set<Category> currentSelectedCategories = (Set<Category>) conAPI.getFieldValue(theContentlet, theStructure.getFieldVar("categoryFieldVarName"));



On Fri, Jan 31, 2014 at 11:46 AM, <<a href="javascript:" target="_blank" gdf-obfuscated-mailto="Q6ijNf6oLHMJ" onmousedown="this.href='javascript:';return true;" onclick="this.href='javascript:';return true;">aric....@...> wrote:
Hello all,


I am trying to get selected category names for the plugin I am currently working on..

What I have right now is the Contentlet object:
Contentlet tmpCon = conList.get(0);

I know for a fact that inside of that Contentlet, there is velocity variable "groupCategory" but when I call:
String grp = tmpCon.getStringProperty("groupCategory"); //this returns null, even though the Contentlet I used for testing has groupCategory filled from the front end

Then I tried:
tmpCon.getCategoryId();
I got some UUID back but I think this is not what I am looking for.


So I tried to list all Categories in the database by:
List<Category> list = APILocator.getCategoryAPI().findAll(user, true);
for(Category c : list) {
  System.out.println(c.getCategoryId() + " "  + c.getCategoryName());
}
I can see all category, both the parents and children.

Taking one of the id shown there, I tried:
String catid = "9d2ea265-ca72-4ab5-90a5-c67c9a36a6b0";
cat = catAPI.find(catid, user, true);
Now this category is returning category name that I need...


The question is, how do I connect Contentlet that I have to this Category API?


Thank you in advance.


Regards,


Aric

--
You received this message because you are subscribed to the Google Groups "dotCMS User Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email to <a href="javascript:" target="_blank" gdf-obfuscated-mailto="Q6ijNf6oLHMJ" onmousedown="this.href='javascript:';return true;" onclick="this.href='javascript:';return true;">dotcms+un...@googlegroups.com.
To post to this group, send email to <a href="javascript:" target="_blank" gdf-obfuscated-mailto="Q6ijNf6oLHMJ" onmousedown="this.href='javascript:';return true;" onclick="this.href='javascript:';return true;">dot...@....
Visit this group at <a href="http://groups.google.com/group/dotcms" target="_blank" onmousedown="this.href='http://groups.google.com/group/dotcms';return true;" onclick="this.href='http://groups.google.com/group/dotcms';return true;">http://groups.google.com/group/dotcms.
For more options, visit <a href="https://groups.google.com/groups/opt_out" target="_blank" onmousedown="this.href='https://groups.google.com/groups/opt_out';return true;" onclick="this.href='https://groups.google.com/groups/opt_out';return true;">https://groups.google.com/groups/opt_out.



--

Christopher Falzone

Interactive Developer


A Q U E N T

Digital, Creative, and Marketing Talent


<a href="http://aquent.com" target="_blank" onmousedown="this.href='http://www.google.com/url?q\75http%3A%2F%2Faquent.com\46sa\75D\46sntz\0751\46usg\75AFQjCNGCaOKRHBIdRAAOFrdesrBUqniSrw';return true;" onclick="this.href='http://www.google.com/url?q\75http%3A%2F%2Faquent.com\46sa\75D\46sntz\0751\46usg\75AFQjCNGCaOKRHBIdRAAOFrdesrBUqniSrw';return true;">aquent.com

<a href="javascript:" target="_blank" gdf-obfuscated-mailto="Q6ijNf6oLHMJ" onmousedown="this.href='javascript:';return true;" onclick="this.href='javascript:';return true;">cfal...@...

--
You received this message because you are subscribed to the Google Groups "dotCMS User Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
Visit this group at http://groups.google.com/group/dotcms.
For more options, visit https://groups.google.com/groups/opt_out.
Reply | Threaded
Open this post in threaded view
|

Re: how to get category name through plugin?

KaRtHiK sHyAm
In reply to this post by aric.t.tan
Hi Aric 

i'm also trying to get selected category names through plugin. but it rendering null values. 

Did you find solution for this? 

if yes, please guide me to render the selected category values.

Thank you
Karthik

On Friday, January 31, 2014 at 10:16:34 PM UTC+5:30, Aric Tatan wrote:
Hello all,


I am trying to get selected category names for the plugin I am currently working on..

What I have right now is the Contentlet object:
Contentlet tmpCon = conList.get(0);

I know for a fact that inside of that Contentlet, there is velocity variable "groupCategory" but when I call:
String grp = tmpCon.getStringProperty("groupCategory"); //this returns null, even though the Contentlet I used for testing has groupCategory filled from the front end

Then I tried:
tmpCon.getCategoryId();
I got some UUID back but I think this is not what I am looking for.


So I tried to list all Categories in the database by:
List<Category> list = APILocator.getCategoryAPI().findAll(user, true);
for(Category c : list) {
  System.out.println(c.getCategoryId() + " "  + c.getCategoryName());
}
I can see all category, both the parents and children.

Taking one of the id shown there, I tried:
String catid = "9d2ea265-ca72-4ab5-90a5-c67c9a36a6b0";
cat = catAPI.find(catid, user, true);
Now this category is returning category name that I need...


The question is, how do I connect Contentlet that I have to this Category API?


Thank you in advance.


Regards,


Aric

--
http://dotcms.com - Open Source Java Content Management
---
You received this message because you are subscribed to the Google Groups "dotCMS User Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/dotcms/d861aa16-b1bc-4f9f-b39e-0449598753d5%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: how to get category name through plugin?

Jason Tesser

On Wed, Aug 23, 2017 at 9:48 AM KaRtHiK sHyAm <[hidden email]> wrote:
Hi Aric 

i'm also trying to get selected category names through plugin. but it rendering null values. 

Did you find solution for this? 

if yes, please guide me to render the selected category values.

Thank you
Karthik


On Friday, January 31, 2014 at 10:16:34 PM UTC+5:30, Aric Tatan wrote:
Hello all,


I am trying to get selected category names for the plugin I am currently working on..

What I have right now is the Contentlet object:
Contentlet tmpCon = conList.get(0);

I know for a fact that inside of that Contentlet, there is velocity variable "groupCategory" but when I call:
String grp = tmpCon.getStringProperty("groupCategory"); //this returns null, even though the Contentlet I used for testing has groupCategory filled from the front end

Then I tried:
tmpCon.getCategoryId();
I got some UUID back but I think this is not what I am looking for.


So I tried to list all Categories in the database by:
List<Category> list = APILocator.getCategoryAPI().findAll(user, true);
for(Category c : list) {
  System.out.println(c.getCategoryId() + " "  + c.getCategoryName());
}
I can see all category, both the parents and children.

Taking one of the id shown there, I tried:
String catid = "9d2ea265-ca72-4ab5-90a5-c67c9a36a6b0";
cat = catAPI.find(catid, user, true);
Now this category is returning category name that I need...


The question is, how do I connect Contentlet that I have to this Category API?


Thank you in advance.


Regards,


Aric

--
http://dotcms.com - Open Source Java Content Management
---
You received this message because you are subscribed to the Google Groups "dotCMS User Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/dotcms/d861aa16-b1bc-4f9f-b39e-0449598753d5%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

--
http://dotcms.com - Open Source Java Content Management
---
You received this message because you are subscribed to the Google Groups "dotCMS User Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/dotcms/CAKKUxWewHEtoPfWVENywZxYSwn_c%3DkU53G9ffjyvHcbzfmcMiA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.