Welcome Guest, Not a member yet? Register   Sign In
Please tell me the better way to create a small site
#1

[eluser]jabga[/eluser]
I am creating a small brochure site. Also I am not so good in PHP.
What I have is blog like paginated front page, register and login user, add, edit, delete news and Tiny MCE editor.

I created a good design in it, and used it. Header, front page, single news page and other static ads etc are OK now.

I am wondering how to handle menu? At the moment, they are static. Used anchor to controller functions.

I would like to have a dynamic menu and other sidebar news widgets.

Please suggest and teach me the right way I should go.

sry about my bad english
#2

[eluser]überfuzz[/eluser]
What features are you looking for in, lets say, the menu?
#3

[eluser]jabga[/eluser]
Yes, the menu is static now

Menu.php view is here, I guess my code will be funny for you guys. But please recommend me how to handle menu Big Grin

Code:
echo anchor('main', 'Home page'); ?>
<?php if (!$auth) {echo anchor('user/register', '   Register');} ?>
<?php if (!$auth) {echo anchor('user/login', '   Login');} ?>
<?php if ($auth  and $loggedusername=='jabga') { echo anchor('admin', '   Admin dashboard');} ?>
<?php if ($auth) {echo anchor('user/logout', '   Logout');}
removed <?php ?> tags ***
$auth is session var ( logged or NUL) , $loggedusername is also session var $_POST['username'] came from Login page lol Tongue



I found it http://www.phpeveryday.com/articles/Code...-P230.html, what is your recommendation guys?
#4

[eluser]BrianDHall[/eluser]
To avoid duplication I do the simplest thing possible - put the menu code in its own view. Load the view into a variable, then pass that variable to my full page template that sticks the menu code in the right place. When you want to add a menu you just open that one file, add that simple line of text to a new menu item, and that's it. Done.

Unless you are building a CMS of some sort, no reason not to just do it that way. Getting fancy with arrays and saving menu items in a database and all that are usually overkill.

I had to go overkill in my last project when multiple nesting of categories and advanced display logic - ugh! You don't really want to bother unless you really need that, big time sink and headache.
#5

[eluser]jabga[/eluser]
Thanks, yes my menu view is inside the header view. It's just one file like you said.

Please can anyone share with me any simple codeigniter site sourse? I would like to see through code.
#6

[eluser]jabga[/eluser]
Hi all. Here is my menu library
Code:
<?php
class MyMenu{        
     function show_menu(){
    $obj =& get_instance();
    $obj->load->helper('url');
    $obj->load->library('session');
    $auth = $obj->session->userdata('user_data') ;
    $loggedusername = $obj->session->userdata('username') ;
          $menu  = "<ul>";
          $menu .= "<li>";
          $menu .= anchor("main","Home");
          $menu .= "</li>";
                  
          if (!$auth) {
        $menu .= "<li>";
        $menu .= anchor('user/register', 'Register');
        $menu .= "</li>";    }    
          
        if (!$auth) {
        $menu .= "<li>";
        $menu .= anchor('user/login', 'Login');
        $menu .= "</li>";    }
            
        if ($auth and $loggedusername=='jabga') {
        $menu .= "<li>";
        $menu .= anchor('admin', 'Admin');
        $menu .= "</li>";    }

                if ($auth) {
        $menu .= "<li>";
        $menu .= anchor('user/logout', 'Logout');
        $menu .= "</li>";    }
          $menu .= "</ul>";
        
          return $menu;
     }
}
?&gt;
But nothing is showing. Blank. Help me to handle menu please
Controller is here
Code:
$this->load->library('MyMenu');
          $menu = new MyMenu;
          $data['menu'] = $menu->show_menu();
        $this->load->view('main/index', $data);




Theme © iAndrew 2016 - Forum software by © MyBB