Sidebar listing "bottom" widgets on a page

Oct 14, 2011 at 3:00 PM

I thought it might be useful to have a thread to share widget templates with other razorC users...  So here is one template that is working fine for me. 

Any suggestions for improvement are of course welcome.

 

@{
     
    var ParentPageID = PageData[0].pID;
    
    var db = Database.Open("MyDatabase"); 
    var selectQueryString = "Select rc_PageWidget.pId                                                  "             
                          + "     , rc_PageWidget.sName                                                "             
                          + "     , rc_PageWidget.wId                                                  "             
                          + "     , rc_PageWidget.wOrderID                                             "             
                          + "     , rc_Widgets.wTitle                                                  "             
                          + "     , rc_Widgets.wText                                                   "             
                          + "     , rc_Widgets.wEditDate                                               "             
                          + "     , rc_Widgets.wFile                                                   "             
                          + "from rc_PageWidget                                                        "             
                          + "inner join rc_Widgets                                                     "             
                          + "on rc_PageWidget.wId = rc_Widgets.Id                                      "             
                          + "where rc_PageWidget.pId= @0 and rc_PageWidget.sName = 'rcBottom'          "             
                          + "order by rc_PageWidget.wOrderId desc                                      ";

                  
    var posts = db.Query(selectQueryString, ParentPageID);
    
}

<li>
	<h2>Contents</h2>
	<ul>
        @foreach (var post in posts)
        {
            <li><a href="#">@post.wTitle</a></li>
        }
    </ul>
</li>

 

Coordinator
Oct 16, 2011 at 1:47 AM

hmmm so what it should do ??? can you explain what is the use for that code? from what i can see it will list wTitle of every widget that is in rcBottom section

BTW you pull all this data (columns) and later in code you do loop and only use wTitle...so there is no need to pull the rest of data if you are not using it.

Oct 24, 2011 at 3:16 PM

Hi, Sorry for this late reaction...

The idea is to enable the creation of a "document" page composed by various sections. The main page is only a place holder for the title of the document, while each section is added as a "bottom" widget, whose title works as the "subsection" heading.  Thus, the "content" widget described here creates an automatic "table of contents", listing each section within the document. 

Yes, additional data columns are not needed; I have only placed them provisionally as I may need them in the future, but of course unused columns can/should be removed.

I know... no rocket science here.  Just trying to provide an example of what unsophisticated users can quickly achieve with razorC. 

Cheers,

Coordinator
Oct 24, 2011 at 3:32 PM

Thanks