Copied to clipboard

Flag this post as spam?

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


  • Dave Rollins 35 posts 48 karma points
    Sep 14, 2009 @ 02:51
    Dave Rollins
    0

    Tags Not Working Right

    I have NOT installed the blog package.

    I am running 4.02.1

    I want to create events and have my users associate tags to them to group them to enhance the event searching experience of our visitors.

    I've added the appropriate reference to the tags data type in xsltconfig file.

      <ext assembly="\bin\umbraco.editorControls" type="umbraco.editorControls.tags.library" alias="tagsLib" />
    
    A) I get the following error any time I try to add a tag to a node:
    Webpage error details
    
    User Agent: Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; Trident/4.0; .NET CLR 1.1.4322; .NET CLR 2.0.50727; .NET CLR 3.0.4506.2152; .NET CLR 3.5.30729)
    Timestamp: Mon, 14 Sep 2009 00:33:23 UTC
    
    Message: Sys.WebForms.PageRequestManagerServerErrorException: Property accessor 'IsValid' on object 'umbraco.editorControls.uploadField' threw the following exception:'Object reference not set to an instance of an object.'
    Line: 4723
    Char: 21
    Code: 0
    URI: http://test.ahcc.org/ScriptResource.axd?d=2D7r9TG6AjMMUanezNeOI7kYW4uhIEdJDv4JKtQ7MY1DpXfOvtZKLJd4GEnyY8Stqt26nC1DBY3bBF8WaMIcI1PTgqZxIEeeYQ7q6sYYruI1&t=ffffffffe4964c0e
    

    B) On my test site I have installed the blog package and I have a different issue:

    The adding of tags works, the cmstags database table looks good with keys and values - but my tag values are node specific - in other words - I dont see tag values entered in for other nodes using the same tags data type (same Tag Group)

    So I am a bit confused. This tags data type is perfect for what I need to do but only if it works :(

    So I have 2 basic questions:

    1) Can someone clarify how the tags data type is "supposed" to work? My understanding is that any node using the tag with the same Tag Group should see the existing tags in the group when you go create  a new node of that type so you you would just check off the approp tags if what you have there is good, or optionally create a new new tag which would be automatically available to any other node in that Tag Group.

    2) I've seen a number of posts about having to install the blog package to get tags working (which you shouldn't have to). - is this the official work around?

    My current work around is to create a drop down datatype of categories for my users to group events by, but tags would be the real solution since it would put my users in charge of their own destinty.

    This is such a cool feature it's killing me that it doesnt work as I would hope.

    Hopefully I am being stupid and there is some switch or something I forgot to flip to make this work :)

     

     

    
    
                    
  • Dave Rollins 35 posts 48 karma points
    Sep 14, 2009 @ 03:28
    Dave Rollins
    0

    OK so I went into the code - downloade the source and it is very easy to see what the problem is... according to me anyways.

    There is this sql code that inits the tag data type of the form and displays the tags that are associated to the node using this code to pull the nodes from the DB

     

    SELECT * FROM cmsTags
                      INNER JOIN cmsTagRelationship ON cmsTagRelationShip.tagId = cmsTags.id
                      WHERE cmsTags.[group] = @group AND cmsTagRelationship.nodeid = @nodeid   

     

    Now.. if we were to change this slightly and do just the following:

     

    SELECT * FROM cmsTags
                      INNER JOIN cmsTagRelationship ON cmsTagRelationShip.tagId = cmsTags.id
                      WHERE cmsTags.[group] = @group   

     

    Everything would begin to work as I would like ... that all tags for a group show on nodes that belonging to the group so you can take your pick from the litter .

    But we would still need to change what is selected etc in the checkbox list something like:

     

    while (rr.Read())
                {
                    ListItem li = new ListItem( rr.GetString("tag"), rr.GetInt("id").ToString());
                    li.Selected = (nodeid == rr.GetInt("nodeId"));
                    tagCheckList.Items.Add(li);
                }

    This would show all the tags in the applicable node group but only pre-check those that are currently stapled to the current node etc...

    Am I missing something?

  • Dave Rollins 35 posts 48 karma points
    Sep 14, 2009 @ 03:48
    Dave Rollins
    0

    Works like a champ...!

    I modified the umbraco.editorControls.tags.DataEditor class

    Sql code was the same as above but the reader code had to look like this:

                while (rr.Read())

                {

                    ListItem li = new ListItem( rr.GetString("tag"), rr.GetInt("id").ToString());

                    li.Selected = (rr.GetInt("nodeId").ToString() == pageId);

                    tagCheckList.Items.Add(li);

                }

    Still no idea what is going on with the error up top on my real site but this fixed the behavior on my test site so now my tag data types actually work properly ... ie. grouping all tag groups like they should on my nodes so I just have to pick off what makes sense on any given node from the selection available - according to me again :)

    I even tested adding new ones and they start showing up unchecked on all my nodes that share the same tag group...

    Does this make sense to anyone?

  • Dave Rollins 35 posts 48 karma points
    Sep 14, 2009 @ 04:24
    Dave Rollins
    0

    OK - there was a sql error... I had to fix since the code there was pulling back duplicates and if you selected a dup when you were adding a new tag to a node you would get a constraint violation etc

    New SQL looks like this --- sorts nice too :)

    SELECT distinct cmsTags.id, cmsTags.tag, ISNULL(cmsTagRelationship.nodeId,0) as nodeId

                      FROM cmsTags left JOIN cmsTagRelationship ON cmsTagRelationship.tagId = cmsTags.id AND cmsTagRelationship.nodeid = @nodeid

                      WHERE cmsTags.[group] = 'default' order by cmsTags.tag

    Seems to work perfectly now.

  • Dave Rollins 35 posts 48 karma points
    Sep 14, 2009 @ 13:19
    Dave Rollins
    0

    As a complete hack, to fix the as of yet unsolved issue with upload control (very weird if you ask me that I put a tags data type on a document and the upload now blows up when you try to add a tag - someone with much more knowldge of umbraco internals probably has an answer) I implemented the following code in the umbraco.editorControls.uploadField class by wrapping the thing in a try catch:

                        try

                        {

                            string tempText = Text;

                            bool isEmpty = String.IsNullOrEmpty(this.PostedFile.FileName);

                            // checkbox, if it's used the file will be deleted and we should throw a validation error

                            if (Page.Request[this.ClientID + "clear"] != null && Page.Request[this.ClientID + "clear"].ToString() != "")

                                return "";

                            else if (!isEmpty)

                                return this.PostedFile.FileName;

                            else if (!String.IsNullOrEmpty(tempText))

                                return tempText;

                            else

                                return "";

                        }

                        catch

                        {

                            return "";

                        }

  • Dave Rollins 35 posts 48 karma points
    Sep 14, 2009 @ 13:39
    Dave Rollins
    0

    I should mention the final sql above is implemented in SQL server - the isnull function will probably hose VistaDB I'll bet.unless they miraculously have the same function.

Please Sign in or register to post replies

Write your reply to:

Draft