Category cloud with image

View: New views
5 Messages — Rating Filter:   Alert me  

Category cloud with image

by Erando (via Magnolia Forums) :: Rate this Message:

| View Threaded | Show Only this Message


Hi,

I want to assign different image icons for different category. How can I do that. I found dialog in Config/modules/data/dialog under Data module in Admin Central. Can I add DMS control here to get image? If yes then how should I export and bootstrap the bundle?

Thanks & Regards,
Amit Patel

--
Context is everything: http://forum.magnolia-cms.com/forum/thread.html?threadId=6893847a-092e-4e6c-a45d-99437b7a5c45


----------------------------------------------------------------
For list details see
http://www.magnolia-cms.com/home/community/mailing-lists.html
To unsubscribe, E-mail to: <user-list-unsubscribe@...>
----------------------------------------------------------------


Re: Category cloud with image

by Antti Hietala :: Rate this Message:

| View Threaded | Show Only this Message

Hi Amit,

How about copying the photo upload mechanism from Contacts? That's by far the quickest way to get category icons.

Add the image control:
1. Copy /modules/data/dialogs/contact/personalTab/photo to /modules/data/dialogs/category/mainTab.
2. Rename the copied node to "icon".
3. Edit some categories to add icons to them.

Render icons next to category labels:
1. Edit the categoryCloud.ft paragraph script. It's in the Categorization module JAR but you can test this out by creating a template in resources and referencing it from the paragraph definition instead.
2. Assign icons to categories.
[#assign itemLevel = item.level]
[#assign itemLink = model.getCategoryLink(itemName)!]
[#assign itemIcon = item.icon!]
3. Render.
<li class="${itemLevel}">
  [#if item.icon?exists]
    <img src="${stk.createImageLink(itemIcon)}" />
  [/#if]
    <a href="${itemLink}" >${itemDisplayName}</a>
</li>

If you prefer a DAM control:
1. Copy a DAM control from /modules/standard-templating-kit/dialogs/generic/controls/tabImage/image.
2. Rename to "iconDMS".
3. Upload some icons into DMS and browse to them from categories with the new DAM control.
4. In paragraph script, assign.
[#assign itemIcon = item.iconDMS!]
5. Render.
[#if item.iconDMS?exists]
  <img src="${stk.getAssetLink(item, 'iconDMS')}" />
[/#if]


--Antti

On Mar 15, 2011, at 3:44 PM, Magnolia Forums (on behalf of Amit Patel) wrote:


Hi,

I want to assign different image icons for different category. How can I do that. I found dialog in Config/modules/data/dialog under Data module in Admin Central. Can I add DMS control here to get image? If yes then how should I export and bootstrap the bundle?

Thanks & Regards,
Amit Patel

--
Context is everything: http://forum.magnolia-cms.com/forum/thread.html?threadId=6893847a-092e-4e6c-a45d-99437b7a5c45


----------------------------------------------------------------
For list details see
http://www.magnolia-cms.com/home/community/mailing-lists.html
To unsubscribe, E-mail to: <user-list-unsubscribe@...>
----------------------------------------------------------------




----------------------------------------------------------------
For list details see
http://www.magnolia-cms.com/home/community/mailing-lists.html
To unsubscribe, E-mail to: <user-list-unsubscribe@...>
----------------------------------------------------------------

Re: Category cloud with image

by Erando (via Magnolia Forums) :: Rate this Message:

| View Threaded | Show Only this Message


Thank Antti! You again came for rescue.

Thanks for wonderful blog http://finnotype.blogspot.com

--
Context is everything: http://forum.magnolia-cms.com/forum/thread.html?threadId=6893847a-092e-4e6c-a45d-99437b7a5c45


----------------------------------------------------------------
For list details see
http://www.magnolia-cms.com/home/community/mailing-lists.html
To unsubscribe, E-mail to: <user-list-unsubscribe@...>
----------------------------------------------------------------


Re: Category cloud with image

by Erando (via Magnolia Forums) :: Rate this Message:

| View Threaded | Show Only this Message


Hi Antti,

How can I get the image icon in category overview page? I tried following but getting error like undefined symbol in categoryOverview.ftl

[code][#assign itemIcon = item.icon!][/code]

--
Context is everything: http://forum.magnolia-cms.com/forum/thread.html?threadId=6893847a-092e-4e6c-a45d-99437b7a5c45


----------------------------------------------------------------
For list details see
http://www.magnolia-cms.com/home/community/mailing-lists.html
To unsubscribe, E-mail to: <user-list-unsubscribe@...>
----------------------------------------------------------------


Re: Category cloud with image

by Erando (via Magnolia Forums) :: Rate this Message:

| View Threaded | Show Only this Message


Hi,

I tried to extend CategoryCloudModel and added following method to get image url.

[code]
public String getCategoryImagePath(){
                try{
            String categoryName = SelectorUtil.getSelector(0);
            Content category = CategoryUtil.getCategoryNodeByName(categoryName);
           
            String imagePath = STKUtil.getAsset(category, "icon", "extras").getLink();
           
            return imagePath;
        } catch (Exception e) {
            return null;
        }
        }
[/code]

Here I am getting [code]NullPointerException[/code] as [code]STKUtil.getAsset(category, "icon", "extras")[/code] returns [code]null[/code]

Can anyone please suggest how to get image if I have Content node of a category?

--
Context is everything: http://forum.magnolia-cms.com/forum/thread.html?threadId=6893847a-092e-4e6c-a45d-99437b7a5c45


----------------------------------------------------------------
For list details see
http://www.magnolia-cms.com/home/community/mailing-lists.html
To unsubscribe, E-mail to: <user-list-unsubscribe@...>
----------------------------------------------------------------