Welcome Guest, Not a member yet? Register   Sign In
And another SEO url question
#1

[eluser]Unknown[/eluser]
Hi there,

I am trying to figure out what the best way of creating dynamic seo urls.

My Database setup:
Quote:id - primairy key
url - the seo url example: "this-is-a-seo-url"
title - page title
msg - page message
class - class (this is the codeigniter class I want to use for this page)
function - the function I want to use within the class
tpl - the template I want to load
homepage - value 0/1 :: If set to 1 I will use the base_url();

Ok, this is clear we moev on to the next step. Generating the menu with seo urls..
Code:
// Connecting to the database
// Getting al the menu items
// looping tru with a foreach loop:

foreach ($query->result_array() as $row):

if($row['homepage'] == 1){ //Homepage isset only use base_url()
$menu_html .=  '<a href="'.base_url().'">'.$row['title_nl'].'</a>';    
}else{
$tmp_class = (isset($row['class']) && $row['class'] != "main" ? $row['class']."/" : "");
$tmp_function = (isset($row['function']) && $row['function'] != "index" ? $row['function']."/" : "");  
$menu_html .=  '< href="'.base_url().$tmp_class.$tmp_function.$row['url_nl'].'">'.$row['title_nl'].'</a>';
}

endforeach;

Legenda:
Quote:page/menu title = Bold
controller= blue
function = orange
parameter = Green
This is the endresult:
Quote:home - base_url()
About - base_url()/martijn-van-hoof
Portfolio - base_url()/portfolio/portfolio-martijn-van-hoof
First Item - base_url()/portfolio/details/first-item
Second Item - base_url()/portfolio/details/second-item
Third Item - base_url()/portfolio/details/third-item
Work- base_url()/work/work-from-martijn-van-hoof
First Item of work - base_url()/work/details/first-item-of-work
Contact - base_url()/martijn-van-hoof

* When I dont specify a controller I want it to use the default_controller (in this case I called it main)
** When I dont specify a function I want it to use the default function (wich in this case is index)
*** If a controller is specified use the specified controller
**** If a function is specified use the specified function

So far so good, but now I am clueless how to solve this problem in a proper way so I am able to reuse this setup for my future projects without entering these lines manually in the routing.php file. What do you think about my url setup and how to fix this problem in a dynamic way? I am curious Smile

Thanks in advance and hopefully I'll get this to work,

Martijn




Theme © iAndrew 2016 - Forum software by © MyBB