Looping through user created pages and place links in the footer

Jul 2, 2012 at 2:43 PM

Hello,

Im looking to loop through all user created pages and place a link to them in the footer. My problem is i cant see any controller where I can pull the data out the database and send it through to the view.

 

Thanks

 

Nicholas

Coordinator
Jul 2, 2012 at 2:47 PM

Hi Nicholas,

What do you mean by "user created pages"?

Could you put a sample using the sample forums: http://sample.nearforums.com/

In which page would you like to see the links on the footer?

 

Regards,

Jorge

Jul 2, 2012 at 2:54 PM

sorry i mean pages created in the admin interface that have the 

/p/terms 

type url

ive found the template that is being printed out to

<p class="requiredLinks">
    @Html.ActionLinkLocalized("About", "Detail", "PageContents", new{name="about"}, null) | 
    @Html.ActionLinkLocalized("Terms and conditions", "Detail", "PageContents", new{name="terms"}, null)
</p>

inside FooterContent.cshtml

Coordinator
Jul 2, 2012 at 3:07 PM
Edited Jul 2, 2012 at 3:07 PM

Hi,

You are right, FooterContent.cshtml is the partial view that is rendered on the footer on every page (with or without having templates enabled).

If you are looking for a built in way to access all the "PageContent" on a view, there isn't: All the PageContents are not loaded on every page, so you can access it on the common view.

If you are looking for a way (overriding the behaviour / forking the solution) to do it: As this partial view is used on every view, you must load it for every request -> Use the BaseController (every controller is a derived BaseController) or an ActionFilter (and register it on the global.asax).

 

Hope it helps,

Jorge

Jul 2, 2012 at 3:14 PM

Brilliant, ill give that a go, thanks for the help and the code, i have learnt loads working with it!!