• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Title in url

#1
Hello, I redo my website my old website, with CodeIgniter. I go through tinymce to create the tutorials, which I register in database.
But I do not know how to display them?
In addition, I want the url to be [TITLE page]

How do you do it all?

Do I have to create a controller for each page?

Thank you in advance for your help.
Reply

#2
See the CodeIgniter User Guide on the News Tutorial for loading pages.

for the page title see documentation in the URL Helper

PHP Code:
$url_title url_title($title); 
What did you Try? What did you Get? What did you Expect?

Joined CodeIgniter Community 2009.  ( Skype: insitfx )
Reply

#3
Thank you for your answer.

I have an idea (good / bad to you to tell me).
I thought: if I create a controller for each category, and that in its controller I put functions, for each software. What do you think ?

So the url will give /[category]/[name_software]

But how in my controller I can only display the article of the id corresponding to my tutorial?
Reply

#4
(07-05-2017, 05:04 AM)tonny16 Wrote: Thank you for your answer.

I have an idea (good / bad to you to tell me).
I thought: if I create a controller for each category, and that in its controller I put functions, for each software. What do you think ?

So the url will give /[category]/[name_software]

But how in my controller I can only display the article of the id corresponding to my tutorial?

If you have categories in the database and then the products in the database, you can make the entire solution database driven (or you can add categories to the database and categorize your products and then use this solution...)

if you want sitename.com/category/product name, you would need to do that in the default controller for the site using the remap function.

PHP Code:
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class 
Welcome extends CI_Controller {
 
 function 
__construct() {
 
parent::__construct(); 
 }
 
 function 
_remap($method){
 
$param_offset 2;

 
// Default to index
 
if ( ! method_exists($this$method)){
 
// We need one more param
 
$param_offset 1;
 
$method 'index';
 
  }

 
// Since all we get is $method, load up everything else in the URI
 
$params array_slice($this->uri->rsegment_array(), $param_offset);

 
// Call the determined method with all params
 
call_user_func_array(array($this$method), $params);
 }

 
       function index($category='',$product='') {
 
// check if the parameters aren't empty
 
if ($category != '' && $product !='') {
 
     // load models for products, filter/clean incoming data, find & display the product page
 
     exit(); // stop executing here
 
}
 
// no category and product, then load the default home page here
 
       

If your category/product names aren't URL friendly, then you'll need to add a column to the database for URL friendly text, populate it and search off of that.
Reply


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2020 MyBB Group.