Copied to clipboard

Flag this post as spam?

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


  • wolulcmit 357 posts 693 karma points
    Apr 19, 2011 @ 18:04
    wolulcmit
    0

    using AutoComplete with inline razor/uQuery

    Am trying to use AutoComplete and grab some data from it
    currently trying to use some inline razor/uquery to achieve this

    <umbraco:Macro runat="server" language="cshtml">
    @using uComponents.Core
    @using uComponents.Core.uQueryExtensions
    @using System.Linq
    @{
    umbraco.presentation.nodeFactory.Node currentNode = uQuery.GetCurrentNode();
    List<umbraco.presentation.nodeFactory.Node> myNodes = uQuery.GetNodesByCsv(currentNode.GetProperty<string>("autoContent")); }
    </umbraco:Macro>

    doesn't give me any output... tried currentNode.GetProperty<string>("autoContent"); but also empty... should I just use xslt instead?

  • Hendy Racher 863 posts 3849 karma points MVP 2x admin c-trib
    Apr 19, 2011 @ 18:10
    Hendy Racher
    0

    Hi Tim,

    Your code looks correct, currentNode.GetProperty<string>("autoContent") should return a csv list of selected IDs as stored by the AutoComplete datatype (should the property alias be "autoComplete" instead of "autoContent" ? just a wild guess).

    Hendy

  • Hendy Racher 863 posts 3849 karma points MVP 2x admin c-trib
    Apr 19, 2011 @ 18:26
    Hendy Racher
    2

    Hi Tim,

    Hopefully this isn't a silly answer, but just added a loop to render the output.

    <umbraco:Macro runat="server" language="cshtml">
    @using System.Linq
    @using umbraco.presentation.nodeFactory
    @using uComponents.Core
    @using uComponents.Core.uQueryExtensions

    @{
    Node currentNode = uQuery.GetCurrentNode();
    List<Node> myNodes = uQuery.GetNodesByCsv(currentNode.GetProperty<string>("autoContent"));

    // Render the output
      <ul>
      @foreach (Node n in myNodes)
      {
     <li><a href="@n.Url">@n.Name</a></li>
      }
      </ul>
    }

    </umbraco:Macro>

    If the values of the currentNode.GetProperty<string>("autoContent") are empty and the property exists, then best to check that the datatype is saving the values, in which case this SQL might be helpful:

    /* property values for a given datatypeId and contentNodeId */

    DECLARE @dataTypeId AS INT
    SET @dataTypeId = 1001

    DECLARE @contentNodeId AS INT
    SET @contentNodeId = 1002

    SELECT *
    FROM cmsPropertyType A
    LEFT OUTER JOIN cmsPropertyData B ON A.id = B.propertyTypeId
    WHERE A.dataTypeId = @dataTypeId
    AND B.contentNodeId = @contentNodeId

    HTH,

    Hendy

  • wolulcmit 357 posts 693 karma points
    Apr 19, 2011 @ 18:49
    wolulcmit
    0

    Hah, what a novel idea that I should render the output :)
    yep, that's cleared things up.... sorry, I'm a complete novice when it comes to uQuery/razor etc c# sort of things. it makes sense now.

  • This forum is in read-only mode while we transition to the new forum.

    You can continue this topic on the new forum by tapping the "Continue discussion" link below.

Please Sign in or register to post replies