Welcome Guest, Not a member yet? Register   Sign In
When I switch to another controller do I really have to rebuild every part on the page?
#1

[eluser]Scouser[/eluser]
What I mean is, I have a page, build up of several partial page 'blocks', with an optional link to "login" which is in fact a different controller. But when I display the login page I still need some (or all) of the page 'blocks' or elements surrounding the login page.

The question is, when I switch to another controller do I really have to rebuild every part on the page or can I just replace the (for example) body part of the page with this new part called "login page"?
#2

[eluser]gtech[/eluser]
Off the top of my head I can think of the following solutions:

1) use frames the easiest way but can be difficult to manage
2) use javascript and ajax calls to load your data dynamically (no need to redirect the browser), then you can say you use web 2.0.
3) store the data you have built up in your session data, so you only need to gather new information required in the controller. This method will still refresh the whole view, but will be more reliable across different browsers
#3

[eluser]Rick Jolly[/eluser]
Adding to gtech's suggestions:
1) Load the partial views within the controller as strings in a library or an application/base/parent controller.
2) Load the partial views within the view. Still requires you to set the data for those views in the controller in a library or application/base/parent controller.
3) Use a helper within the view to load each partial view. Doesn't require messing with the controller.
Search for hmvc on these forums.
#4

[eluser]leonglass[/eluser]
Not sure if this is quite what you meant but I have a single view file that lays out a page. All controllers eventually load this page and I load different sections (which are different files) with the true argument storing the string returned in a data array. So I have different view files

page_view
header
left
footer

that are loaded for each page regardless of the controller used. Each separate function of each controller constructs its own page using the appropriate view file and passes this data to the final view_page file for final rendering.

I hope that made sense.
#5

[eluser]Scouser[/eluser]
Thanks for the replies
#6

[eluser]Edemilson Lima[/eluser]
Quote:2) use javascript and ajax calls to load your data dynamically (no need to redirect the browser), then you can say you use web 2.0.

That was my first idea when I started to play with AJAX. But, as nothing is perfect, the Search Engines do not execute Javascript code. If you load data using JS, it will be invisible to SE bots and the contents of your web site will not be indexed on them.




Theme © iAndrew 2016 - Forum software by © MyBB