session - different views - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20) +--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23) +--- Thread: session - different views (/showthread.php?tid=56560) |
session - different views - El Forum - 01-02-2013 [eluser]Unknown[/eluser] Hello, I'm a student who is not really experienced yet with webdev/php/ci and Ive been looking for help in existing topics but since i'm not native English it's something a bit harder to understand certain things. So I prefered starting my own question so the advice I (hopfeully) get would be easier to understand. For a school project I'm trying to use the CI framework while learning PHP aswell. I'm getting the picture with the basics, I created a simple login/reg functionality to start with, with a few controllers, views and a User model. I currently have my header and footer view split up from the content views (each page is a view). When I login, I'm correctly directed to the members view. But there my issue starts... I currently have no idea how (and where) I have to work with the session to show a different header when logged in, so I can add extra functionaltiy/links in the menubar. For continuity reasons i currently use some statements in my views (if no session, show 'login', if session, show 'logout' , to give a quick example) but this is not the correct way ofcourse. I've tried to find it myself to do something with the load->views so the correct header shows but my tries fail each time. Anyone who has the best (codeigniter/mvc) way of implementing this? Thanks in advance session - different views - El Forum - 01-02-2013 [eluser]InsiteFX[/eluser] Check your session in your controller then load the nav view that you need in your controller. Credit Author: Adam Griffiths Auth 1.06 Code: <ul id="navigation"> session - different views - El Forum - 01-03-2013 [eluser]bigbusty[/eluser] you should do that in your controller session - different views - El Forum - 01-03-2013 [eluser]Unknown[/eluser] Avoiding the if in the view is indeed my intention. Currently i only know to have an if-else with the load->views. If i'm in the session I load the headermembers_view, and if not, the regular header_view. but i do repeat this in every controller for every page. |