Welcome Guest, Not a member yet? Register   Sign In
Use title in URL
#11

(02-25-2020, 03:59 AM)John_Betong Wrote: @omid_student,
> You say when i insert record data into database,same time add url readable string in database?

It was a long time ago and I thought it would cater for some title not exactly matching the Xrl  field. I think the url_title(...) function caters for at least 99% of cases and better to slightly adjust the title instead of having two separate field.
Yes i know but i cannot decode it
I think when i insert product to database,same time make url title for each product
Reply
#12

(This post was last modified: 02-25-2020, 06:44 AM by zahhar.)

(02-25-2020, 04:05 AM)omid_student Wrote: Yes i know but i cannot decode it
I think when i insert product to database,same time make url title for each product

Why you need to decode it? There should not be a need for it. It would be bad design.

Your initial approach is almost fine: 
PHP Code:
$title "Agile Digital Project Manager/£475 - 525 pd/6 months/London";
$url_title url_title($title'underscore'); 

However, I would recommend to enrich it with 3 following items:
  1. Use minus (dash) sign as a separator insted of underscore - for SEO reasons
  2. Convert it lowercase as makes no sense to keep the case in URL (url_title() has 3rd param to cast to lowercase)
  3. Make it unique by combining with record unique ID (table ID will work fine)
So you will get:
PHP Code:
$id 12345//it should come from your DB table record ID
$title "Agile Digital Project Manager/£475 - 525 pd/6 months/London";
$url_title url_title($title'-'TRUE)."-".$id;

//Output:
//agile-digital-project-manager-475-525-pd-6-months-london-12345 

This way you ensure each $url_title is unique, even when there are job ads with same titles (e.g. "Project Manager"). Then you store in DB both $title and $url_title, and update $url_title every time $title changes. And when/if you want to get $title by $url_title, you can do one SQL query ("where url_title = %s", $url_title).
Reply
#13

(This post was last modified: 02-25-2020, 06:56 AM by omid_student.)

(02-25-2020, 06:40 AM)zahhar Wrote:
(02-25-2020, 04:05 AM)omid_student Wrote: Yes i know but i cannot decode it
I think when i insert product to database,same time make url title for each product

Why you need to decode it? There should not be a need for it. It would be bad design.

Your initial approach is almost fine: 
PHP Code:
$title "Agile Digital Project Manager/£475 - 525 pd/6 months/London";
$url_title url_title($title'underscore'); 

However, I would recommend to enrich it with 3 following items:
  1. Use minus (dash) sign as a separator insted of underscore - for SEO reasons
  2. Convert it lowercase as makes no sense to keep the case in URL (url_title() has 3rd param to cast to lowercase)
  3. Make it unique by combining with record unique ID (table ID will work fine)
So you will get:
PHP Code:
$id 12345//it should come from your DB table record ID
$title "Agile Digital Project Manager/£475 - 525 pd/6 months/London";
$url_title url_title($title'-'TRUE)."-".$id;

//Output:
//agile-digital-project-manager-475-525-pd-6-months-london-12345 

This way you ensure each $url_title is unique, even when there are job ads with same titles (e.g. "Project Manager"). Then you store in DB both $title and $url_title, and update $url_title every time $title changes. And when/if you want to get $title by $url_title, you can do one SQL query ("where url_title = %s", $url_title).

Oh yes your solution is the best
I thought that i encode and decode it for search in database
But now with your solution,i encode it and save to database and search with it
Thanks

(02-25-2020, 06:40 AM)zahhar Wrote:
(02-25-2020, 04:05 AM)omid_student Wrote: Yes i know but i cannot decode it
I think when i insert product to database,same time make url title for each product

Why you need to decode it? There should not be a need for it. It would be bad design.

Your initial approach is almost fine: 
PHP Code:
$title "Agile Digital Project Manager/£475 - 525 pd/6 months/London";
$url_title url_title($title'underscore'); 

However, I would recommend to enrich it with 3 following items:
  1. Use minus (dash) sign as a separator insted of underscore - for SEO reasons
  2. Convert it lowercase as makes no sense to keep the case in URL (url_title() has 3rd param to cast to lowercase)
  3. Make it unique by combining with record unique ID (table ID will work fine)
So you will get:
PHP Code:
$id 12345//it should come from your DB table record ID
$title "Agile Digital Project Manager/£475 - 525 pd/6 months/London";
$url_title url_title($title'-'TRUE)."-".$id;

//Output:
//agile-digital-project-manager-475-525-pd-6-months-london-12345 

This way you ensure each $url_title is unique, even when there are job ads with same titles (e.g. "Project Manager"). Then you store in DB both $title and $url_title, and update $url_title every time $title changes. And when/if you want to get $title by $url_title, you can do one SQL query ("where url_title = %s", $url_title).
Dy you can help me about reload config file when process is running?
Reply
#14

@omid_student
> I thought that i encode and decode it for search in database

Here's an AJAX search demo with source that searches for words in the database:

https://johns-jokes.com/downloads/sp-e/jb-ajax-search/
Reply
#15

(02-25-2020, 07:55 AM)John_Betong Wrote: @omid_student
> I thought that i encode and decode it for search in database

Here's an AJAX search demo with source that searches for words in the database:

https://johns-jokes.com/downloads/sp-e/jb-ajax-search/

Thanks
Reply
#16

(02-19-2020, 02:04 AM)omid_student Wrote: Hi
In my shop project,i need show product title in url
Example:
example.com/product/laptop sony/vio
laptop sony/vio is product tite

How do some sites show title in url and encode and decode it and search product?

In codeignter we can use below code
$title = "Agile Digital Project Manager/£475 - 525 pd/6 months/London";
$url_title =  url_title($title, 'underscore');

But how do decode it?
Reply




Theme © iAndrew 2016 - Forum software by © MyBB