Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Martin 48 posts 69 karma points
    Dec 24, 2010 @ 01:49
    Martin
    0

    Linking Tag Group to a Node Property?

    Hi all,

    I'm only a few days into using Umbraco, but already very impressed with how things are working out.

    I eventually managed to get Blgo4Umbraco working, with multiple blogs configured on a single install.

    The problem I now have is that the tags are shared across all of the blogs.

    Has anyone worked how to to limit the tags to only the blogs where they are used? Or to implement the 'group' on the tags successfully?

    Ideally, I'd like to customise the tag list to only show tags from a certain group - and automatically set this group when a new tag is added (based on a recursive node property perhaps?

    Any help much appreciated.

    My favourite packages so far:

    Blog4Umbraco (if the install was more obvious for 4.5 and the project better maintained!)
    DisableDelete
    AttackMonkey_Tab_Hider
    TagManager

    Haven't really found anything very good for basic contact forms as yet (ideally wanted something to post back via ajax and email the resulting name/email/comments to an email address based on another recursive node property -- anyone seen anything like that?).

    Any other must have package recommendations would be well received - I've got a few to look into on sitemaps and related pages.

    Thanks!

    Martin

  • Martin 48 posts 69 karma points
    Dec 30, 2010 @ 14:53
    Martin
    0

    For anyone who's interested in doing this (and willing to get stuck into recompiling the core Umbraco code base), you should add the following code snippets to the onInit method of the umbraco.editorControls.tags.DataEditor.cs script file: 

    string realGroup = "";

     

     

    string templateGroupValue = "";

     

     

    Document thisPage;

     

    thisPage =

     

    new Document(int.Parse(pageId));

     

     

     

    if (_group.StartsWith("$")) {

    realGroup = _group.Substring(1);

     

     

    if (realGroup != null) {

    templateGroupValue = thisPage.getRecursiveProperty(realGroup).Value.ToString();

     

     

    if (templateGroupValue != null) {

    _group = templateGroupValue;

    }

    }

    }

    Just above the line:

    tags = umbraco.cms.businesslogic.Tags.Tag.GetTags(int.Parse(pageId), _group);

     

    And then add the getRecursiveProperty method to the umbraco.cms.businesslogic.Content class:

     

     

    /// <summary>

     

     

    /// Retrieve a Property recursively given the alias

     

     

    /// </summary>

     

     

    /// <param name="alias">Propertyalias (defined in the documenttype)</param>

     

     

    /// <returns>The property with the given alias</returns>

     

     

    public Property getRecursiveProperty(string alias)

    {

     

     

    ContentType ct = this.ContentType;

     

     

    if (ct == null)

     

     

    return null;

    propertytype.

     

    PropertyType pt = ct.getPropertyType(alias);

     

     

    if (pt == null) {

     

     

    if (this.Parent != null) {

     

     

    Content thisParent = new Content(this.ParentId);

     

     

    return thisParent.getRecursiveProperty(alias);

    }

     

    else {

     

     

    return null;

    }

    }

     

    else {

     

     

    return getProperty(pt);

    }

    }

  • Martin 48 posts 69 karma points
    Dec 30, 2010 @ 14:57
    Martin
    1

    PS. I should also add that you can then modify the BlogCategories XSLT script to pull the newly limited list of tags (which then allows you to have lists of tags per blog, rather than one global one):

     

    Add the variable declaration:

    <xsl:variable name="tagGroup" select="$currentPage/ancestor-or-self::*/customTagGroup"/>

    Then modify the tag selection from:

    <xsl:for-each select="tagsLib:getAllTagsInGroup('default')/tags/tag">

    to:

    <xsl:for-each select="tagsLib:getAllTagsInGroup($tagGroup)/tags/tag">

  • Martin 48 posts 69 karma points
    Dec 30, 2010 @ 14:59
    Martin
    0

    (The "customTagGroup" being a document type property name and also the tag group setting on the tags data type, e.g. "$customTagGroup").

  • Jamie Howarth 306 posts 773 karma points c-trib
    Jan 14, 2011 @ 12:58
    Jamie Howarth
    0

    Been thinking on exactly how to do this - perfect. I'll add this to the workitems for B4U. Have you submitted it as a patch to the Umbraco core?

    Best,

    Benjamin :-)

  • Martin 48 posts 69 karma points
    Jan 14, 2011 @ 13:57
    Martin
    0

    Hi Benjamin,

    I'm not setup to get involved in version controlled changes, so haven't submitted anything to the core. You are more than welcome to take my code above and use it as you wish though!

    Kind regards,

    Martin

Please Sign in or register to post replies

Write your reply to:

Draft