Jump to content

roadie

New Members
  • Posts

    5
  • Joined

  • Last visited

    Never

Everything posted by roadie

  1. Wooow! Things got pretty hot i here! I just want to clarify few things: 1. I start learning PHP about a year ago and I code only during the night when the kids are sleeping. Just kidding! 2. I came to this website to learn from others' experience 3. I want to stick with procedural until I learn some basics for good programming. About my code... The function "find_selected_item_id()" tells me all the time what kind of view was selected from the top_menu and includes in the content.php pieces of codes accordingly. Then the same function tells me what item i selected from the code i just included, and then includes another piece of code or just display a page. function display_top_menu(){ echo "<ul>"; $section_set = get_all_visible_sections(); while($section = mysql_fetch_array($section_set)){ echo "<li><a href=\"index.php?sec={$section['id']}&view={$section['view_type']}\">" . $section['name'] . "</a></li>"; } echo "</ul>"; } content.php <?php find_selected_item_id(); if (isset($sel_sec)){ //a section was selected from the top-menu $view = $_GET['view']; $file = "views/{$view}.php"; include $file; }elseif (isset($sel_pag)){ //a page was selected from the pages_list include('views/page.php'); }elseif (isset($sel_cat)){ //a cateory was selected from the categories_list include('views/users_list.php'); }elseif (isset($sel_usr)){ include('views/user.php'); //a user/company was selected from the users_list } else{ include('modules/front_page.php'); //nothing selected, the module "front_page" is included } ?> ####the first type of view- a section has just a single page under it ####the page.php is included if "index.php?sec=1&view=page" was selected page.php <?php if(isset($_GET['pag'])){ $page_set = get_page_by_id($_GET['pag']); }else{ $page_set = get_pages_by_section_id($_GET['sec']); } $page = mysql_fetch_array($page_set); if ($page['extra_module'] != NULL){ $module = "modules/" . $page['extra_module'] . ".php"; include $module; } else{ echo "<h2>" . $page['name'] . "</h2><br />"; echo $page['content']; } ?> ####second type of view - a section has more pages under it but I want to see a list of them with the link to the full article for each link ####index.php?sec=2&view=pages_list ####if I choose any of the links then selected_item_id() will give me the "pag" and then the pag.php will be included pages_list.php <ul class="pags"> <?php $page_set = get_pages_by_section_id($_GET['sec']); while($page = mysql_fetch_array($page_set)){ echo "<li><a href=\"index.php?pag=" . urldecode($page['id']) . "\"> {$page['name']}</a></li>"; } ?> </ul> ####the third type of view - a section has more categories, and no direct articles under it. It will give a list of all the categories ####index.php?sec=3&view=categories_list if I choose any of the links then selected_item_id() will give me the "cat" categories_list.php <ul class="cats"> <?php $category_set = get_categories_by_section_id($_GET['sec']); while($category = mysql_fetch_array($category_set)){ echo "<li><a href=\"index.php?cat=" . urldecode($category['id']) . "\"> {$category['name']}</a></li>"; } ?> </ul>
  2. Rectification: not everyone, but most of the people.... So, it's nothing wrong with code? Roadie
  3. Hi guys! I have some code like this, but everyone on the internet says that globals are wrong. Need your advice. I have a function which tells me what was selected: section, category, page or user. According to that selection, code.php will include different pages. Is this wrong? If yes, how can accomplish something like this? function find_selected_item_id() { global $sel_sec; global $sel_cat; global $sel_pag; global $sel_usr; if (isset($_GET['sec'])) { $sel_sec = $_GET['sec']; $sel_cat = NULL; $sel_pag = NULL; $sel_usr = NULL; } elseif (isset($_GET['cat'])) { $sel_sec = NULL; $sel_cat = $_GET['cat']; $sel_pag = NULL; $sel_usr = NULL; } elseif (isset($_GET['pag'])){ $sel_sec = NULL; $sel_cat = NULL; $sel_pag = $_GET['pag']; $sel_usr = NULL; } elseif (isset($_GET['usr'])){ $sel_sec = NULL; $sel_cat = NULL; $sel_pag = NULL; $sel_usr = $_GET['usr']; } else { $sel_sec = NULL; $sel_cat = NULL; $sel_pag = NULL; $sel_usr = NULL; } } content.php <?php find_selected_item_id(); if (isset($sel_sec)){ //a section was selected from the top-menu $view = $_GET['view']; $file = "views/{$view}.php"; include $file; }elseif (isset($sel_pag)){ //a page was selected from the pages_list include('views/page.php'); }elseif (isset($sel_cat)){ //a cateory was selected from the categories_list include('views/users_list.php'); }elseif (isset($sel_usr)){ include('views/user.php'); //a user/company was selected from the users_list } else{ include('modules/front_page.php'); //nothing selected, the module "front_page" is included } ?>
  4. This is the site I'm working on... http://qinghai_links.byethost10.com
  5. Hi guys! I start learning PHP a year ago or so, followed few tutorials, created a simple CMS and now I want to start my first BIIIIIG project, just for learning. There are LOTS of things I don't know yet, and I'd appreciate your help. I don't know any OOP so I'd like to do it in procedural way. I want to create a CMS that will look something like this: | Home | About | Classifieds | News | Whatever | Contact | The structure I'm thinking is: Sections Categories Pages The top menu is created by fetching all the Sections from the database with a function "display_top_menu()" + |Home| -index.php |About| -1 level- Section - 1 single page |Classifieds| - 3 levels - Section -Categories-Pages |News| -2 levels -Section - Pages |Contact| - 1 level- but I want to be able to add some custom code, to display the contact form for example My questions are: 1. How can I make the Sections to display differently? Adding a field "type" or "view" in the section table will help? Is this the right way? ex: type1 (About) -display full article belonging to this section type2 (News) -display a list of articles belonging to this Section with links to the the full article type3 (Classifieds) -display a list of categories with links to Category1, Category2,... type4 (Contact) - custom code 2. Is it ok that all this code to run on a single page which I'll call it "content.php", for example? Or I should create separate pages, for each type? 2. The Home page has to be a Section also, or not? I hope you can understand me. I don't know most of the programming terminology.... Roadie
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.