Copied to clipboard

Flag this post as spam?

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


  • Carlos 338 posts 472 karma points
    Jun 25, 2012 @ 22:04
    Carlos
    0

    Query string from droplist multiple Datatype in Razor

    How would you get a query string from a droplist multiple Datatype?  

    We are trying to pull all pages with a certain DocType.  We are able to pull them by the creatorName. We have "categories" set up in a Dropdown List Multiple Datatype.  We are trying to pull the onces with certain categories selected.  As you can see in the code we have a Helper Method we are passing a value to call PostListings. As you can see we have the Author in there and that query string is already working.  We need to know how to do this for the  Dropdown List Multiple in which we have our Categories predetermined. And the authors can choose multiple categories. We need to try to pull those Nodes that belong to those categories.

    Below we have a list of the categories we are getting from the Dropdown List Multiple Datatype, then the If/Else passing the PostListing to the Helper Method.  How would we pull only the Nodes with those specific "Categories".  Does that make sense?  

    Thanks in advance.

     Our code is below.

    This is our list of Categories with links.  This is actually a separate file from the main list of Nodes we are trying to get.

    var baseNode @Model.AncestorOrSelf("DWTBlogLanding");
    XPathNodeIterator myValues umbraco.library.GetPreValues(12080);
    myValues.MoveNext();
    XPathNodeIterator preValueIterator myValues.Current.SelectChildren("preValue","");
      
     <h3>@Dictionary.DWTCategories</h3
      <ul>
    @while(preValueIterator.MoveNext(){
    <li>
    <href="@[email protected]">
    @preValueIterator.Current.Value  <text>(</text>@preValueIterator.Current.Value.Count()<textnot quite right)</text>
    </a>
    </li>
    }
    </ul>

     

    This is in our other page that has our IF/ELSE and our HelperMethod

     @*AUTHORS*@
      if(!String.IsNullOrEmpty(Request.QueryString["author"])){
         @PostListings(@Model.NodeById(1089).Descendants("ScienceResearchUpdatesPost").Where("creatorName == @0"Request.QueryString["author"]).OrderBy("CreateDate desc").Skip(currentPage*itemsPerPage).Take(itemsPerPage));                                                     
       }
      @*CATEGORIES*@
      else if(!String.IsNullOrEmpty(Request.QueryString["dwtBlogCategories"])){
          @PostListings(@Model.NodeById(1089).Descendants("ScienceResearchUpdatesPost").Where(Request.QueryString["dwtBlogCategories"]).OrderBy("CreateDate desc").Skip(currentPage*itemsPerPage).Take(itemsPerPage));
      }
      @*DATES*@
      @*
      else if(){
                
      }
      *@
      @*NOTHING*@
      else{
         @PostListings(@Model.NodeById(1089).Descendants("ScienceResearchUpdatesPost").OrderBy("CreateDate desc").Skip(currentPage*itemsPerPage).Take(itemsPerPage));  
      }
    @*Helper Method*@

    @helper PostListings(DynamicNodeList list)

     var baseNode @Model.AncestorOrSelf("DWTBlogLanding");
     <ul class="dwtPostList">
     @foreach(DynamicNode nodeItem in @list){
      <li>
        <h3>
           <href="http://website.test.dmns.org/@(baseNode.Url)Post/?nid=@(nodeItem.Id)">@nodeItem.Name</a>
        </h3>
      <div class="dwtPosted">Posted @nodeItem.CreateDate by @nodeItem.CreatorName</div>
      @Html.Raw(@nodeItem.GetProperty("landingPageContent").Value)  
       @*@Html.Raw(@nodeItem.GetProperty("bodyText").Value)*@
         <div class="dwtBtnHolder">
           <href="http://website.test.dmns.org/@(baseNode.Url)Post/?nid=@(nodeItem.Id)" class="buyNowBtn">Read More</a>
         </div>
         
         
          
                                             
        @if(@nodeItem.HasValue("dwtBlogCategories")){                                       
           <div class="dwtBlogCatTagContainer">
           <div class="dwtPostListCategories">
           <spanCategories</span
          <ul class="dwtPostListCategoriesList">   
                                                  
          @{var categories @nodeItem.GetProperty("dwtBlogCategories").Value.Split(",".ToCharArray());}
            @foreach(var in categories){
              <li><href="@baseNode.Url?category=@c">@c</a></li>                      
             }
             </div>                       
            </div
          }         
      </li>
     }
     </ul>
  • 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