default userpic

Category Custom Fields

Vote 0 Votes

I've got an issue I've been scratching my head all day about. I've got several custom fields setup as category fields. They work perfect inside of a category page itself. However, now I'm trying to access these fields from a widget on an entry page and I just can't figure it out. I'm trying to have the widget set the current category that the entry is in and then go and grab the custom category fields that I have made for it, does that make sense at all? Any help here would be much appreciated!

Reported on Movable Type 4.2

16 Replies

| Add a Reply
  • Try to place them within:

    <mt:IfCategory type="primary">
    your category custom fields here
    </mt:IfCategory>

    And if you would like to use this coding inside a sidebar widget, you may like to surround the above with:

    <mt:If name="entry_archive">
    ...
    </mt:If>

  • Thanks for the reply. When I try that method, it gives me a publishing error looking for a label attribute on the IfCategory tag. Would something like this work:

    <mt:If name="entry_archive">
    <mt:IfCategory label="<$mt:EntryCategory$>">
    <div class="box red content contact-us">
    	<div class="title content"><h2><$mt:CategoryLabel$>'s Mini Bio</h2></div>
    	<div class="box-content-beige" style="height: 160px;">	
    		<div class="inner">
                       <div style="float: left; width: 150px;"><a href="<$mt:CategoryArchiveLink$>" border="0"><img src="imagepath" alt="<$mt:CategoryLabel$>" /></a></div>
                       <MTDataPlayerBioMini>
    		</div>		
    		</div>
    </div>
    </mt:IfCategory>
    </mt:If>
    

    I'm hoping the code shows you what I'm going for. Earlier I was trying to use where you are using the IfCategory. This approach was working and displaying data correctly but obviously it was looping through every category in the system instead of just the current category. I just can't figure out how to limit it to just look at the category that the entry is in, if that makes sense. I have a few hairs going gray because of this today I think!

  • default userpic

    I guess the main problem is in addition to the MTDataPlayerBioMini field I also need to be able to access the CategoryLabel, CategoryArchiveLink, and CategoryBasename and I can't seem to access any of these without using . However I can't figure out how to use in the context of just this particular category instead of looping through every one in the system. I'm losing hope, any one else have any thoughts?

  • In the coding sample you've provided about replace <$mt:EntryCategory$> with the label of the category you want to display...

  • default userpic

    But it needs to be variable depending on that particular entry category instead of hardwired. Even then I still can't use CategoryLabel, CategoryArchiveLink, and CategoryBasename because it spits out publishing errors about using them out of context without being in .

  • I think you have to explain from scratch the following:

    1) what you want to obtain;

    2) on what page types you would like to obtain that;

    3) on which template will you place the coding you seek.

    Also, a direct link to your web site might help.

  • default userpic

    Sorry for the confusion....

    1) I'm trying to be able to access the following fields: CategoryLabel, CategoryArchiveLink, and CategoryBasename, in addition to my custom category field MTDataPlayerBioMini.

    2) It's going in a sidebar widget which will be featured on entry archive pages, just standard posts in the blog.

    3) Above, going in a widget to work on entry archives.

    I've gotten the widget working on the actual CATEGORY page but I can't get it working on any ENTRY pages because I can't figure out how to access category data pertaining to the category that the current entry is in. I always get publishing errors when trying to access those fields if I don't wrap them in a because the widget is being featured on an entry page. I just can't figure out how to code it to where it can pull those category fields on an entry page.

    Does that make any more sense or just rubbish?

  • Thanks for your explanation!

    Then just put this one at work!

    <mt:If name="entry_archive">
    <mt:If tag="EntryCategory">
    <div class="box red content contact-us">
    <div class="title content"><h2><$mt:CategoryLabel$>'s Mini Bio</h2></div>
    <div class="box-content-beige" style="height: 160px;">
    <div class="inner">
    <div style="float: left; width: 150px;"><a href="<$mt:CategoryArchiveLink$>" border="0"><img src="imagepath" alt="<$mt:CategoryLabel$>" /></a></div>
    <MTDataPlayerBioMini>
    </div>
    </div>
    </div>
    </mt:If>
    </mt:If>

  • default userpic

    NP, thanks for trying to help as I'm truly going insane. That is pretty much what I've been trying to do, except I get the following publishing error when I try that code:

    Error in tag: Error in tag: You used an tag outside of the proper context.

    It doesn't seem to let me access those category tags from there like this. Any thoughts or other ideas? I've tried so many different ways now and it's just not working for me.

  • default userpic

    Also, my MT version is as follows:

    Movable Type Pro version 4.23-en with: Community Pack 1.61, Professional Pack 1.21

    If it makes a difference at all....

  • default userpic

    Still not working....=( Anyone else care to offer to ideas or help here?

  • Why don't you drop me a line by email with access to your MT Admin and I will try to patiently get that working for you?

    If I could get that fixed for your quick fast you owe me nothing, or you can make a small donation if you want.

  • This approach was working and displaying data correctly but obviously it was looping through every category in the system instead of just the current category.

    SvenCondon
    http://recumbentexercisebikesale.com

  • I think we have a similar issue - wondering if you found a solution to your problem.

    Here's mine:

    I want to have a Navigation Bar that list 4 or 5 'custom' categories.

    Currently ALL of my MT:cats are Parent level - and I want to keep it that way.

    So, I made a custom field in Categories for these 'fake new parent categories' - So, custom field drop down - New Cat1, New Cat2, etc.

    I can list the categories with New Cat1 / Old Cat - but I can't figure out how to get the New Cats to sort all of the Old Cats -

    Am I making any sense? It would seem mt:loop - but I've all but given up

    Suggestions?

  • Fwiw, I'm having essentially the same issue with custom fields for users. I have several custom fields for users in our system.

    In the middle of an entry context, I can obviously access the pre-baked MT tags like:

    mt:entryauthordisplayname

    but I can't get to the custom fields for the entryauthor without -- in the middle of the entry -- looping through all authors, finding the one that matches the entryauthor, and then getting at the custom fields that way. It's not pretty.

    What I'd like to be able to do for a custom field like this:

    mt:AuthorDataFavoriteColor

    is be able to say something like this:

    mt:EntryAuthorDataFavoriteColor

    any suggestions for this or the custom category fields discussion above would be wonderful.

    thanks!

    -tony

  • you said it much better than me - but that's exactly what I'm trying to do with a Category.

    I'm thinking it maybe a little tougher on a category since each is associated with an infinite amount of entries - but it would seem if I just want a list of Categories that have a specific custom field - it shouldn't be this hard - unless I'm just not thinking about it right...

    Any admins willing to chime in?

Add a Reply

If you need to share template code, replace all the "<" signs with "&lt;" or use this utility.

Forum Groups

1773 6162

Last Topic: Excluding categories from blog by kholechek on Feb 9, 2012

86 302

Last Topic: website entries by masoud on Oct 26, 2011

1429 5077

Last Topic: What apocalypse hit this community in the middle of 2011? by 75th on Feb 10, 2012

695 2910

Last Topic: Insert Image / File Fails by Russ Miller on Feb 10, 2012

84 291

Last Topic: How to have some other characters in entry basename automatically written by Afshin Haghighatnia on Dec 22, 2011

173 737

Last Topic: About the MT version stated in HTML source by Alex E. Schneider on Feb 7, 2012

190 567

Last Topic: Analytics Reporting by michael webster on Feb 5, 2012

48 210

Last Topic: An idea and also a request by Afshin Haghighatnia on Jun 29, 2011

64 246

Last Topic: jQuery in MT 5.1 still at 1.4 - why? by perlmonkey on May 25, 2011

code.sixapart.com

137 478

Last Topic: Getting a thumbnail with xpath by Peter on Mar 13, 2011

222 720

Last Topic: Custom Field for Asset Not Appearing by android on Feb 9, 2012