TalkPHP
 
 
Account Login
Latest Articles
» The basic usage of PHPTAL, a XML/XHTML template library for PHP
» Vulnerable methods and the areas they are commonly trusted in.
» Simple way to protect a form from bot
» The Basics On: How Session Stealing Works
» How to keep your forms from double posting data
IRC Channel
IRC Speech Bubble Join the friendly bunch on IRC...
(#TalkPHP on Freenode)

...Also available via a web interface.

See this thread for information on the TalkPHP Free Hugs Initiative™. Subject to availability.
Associates
Associates
CSS Tutorials
Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old 12-29-2009, 08:59 PM   #1 (permalink)
The Wanderer
Newcomer 
 
Parvus's Avatar
 
Join Date: Aug 2008
Posts: 21
Thanks: 1
Parvus is on a distinguished road
Default vB style url's/navbar, how ?

Hi all,

I'm having a question that is driving me kinda nuts right now.
I really like the way vB handles the url's and makes the navbar and I would like to be able to make the same sort of url's and navbar.

First I was looking how the url's where made so nice, so I did some research on mod_rewrite and I am able to make some nice url's, but I'm still with the question how vB handles a url like:
http://www.talkphp.com/general/ and http://www.talkphp.com/general/1-example/. I know that vB (in the second case) just gets the number of the topic and shows it, no mather what is behind the number, but how does vB handle the first case ?
I had a thought that maybe vB takes 'general', looks for a title in a db and gets stuff, but then I thought, how does it handle 'tips and tricks' while the url says /tips-tricks/ . . .

The navbar was also driving my head nuts, but I now know (or actually think) that it gets a parent/child id and looks up the parents/children and then makes the navbar.

Could someone help me in how to make does url's and/or enlight me with some idea's on how to implement this easily ?

*And since we're in between the holidays, happy holidays everone =]
~Parvus
Parvus is offline  
Reply With Quote
Old 12-29-2009, 09:14 PM   #2 (permalink)
is cute and cuddly
 
delayedinsanity's Avatar
 
Join Date: Mar 2008
Location: Vegas, Baby
Posts: 963
Thanks: 31
delayedinsanity is on a distinguished road
Default

It probably uses what's called a slug, and descriptive name. The descriptive name can be anything, "General Information and Your Toilet" whereas the slug would be url readable (and unique), such as "general-toilet-info".

Your table schema would include this, most likely as an index used for lookups. Parse the url, get the slug, select the appropriate category information and grab your data from there.
delayedinsanity is offline  
Reply With Quote
The Following User Says Thank You to delayedinsanity For This Useful Post:
Parvus (12-29-2009)
Old 12-29-2009, 09:56 PM   #3 (permalink)
The Wanderer
Newcomer 
 
Parvus's Avatar
 
Join Date: Aug 2008
Posts: 21
Thanks: 1
Parvus is on a distinguished road
Default

That would indeed be a simple solution, ty delayedinsanity =]
Parvus is offline  
Reply With Quote
Old 12-31-2009, 07:20 AM   #4 (permalink)
The Contributor
 
Join Date: Feb 2007
Posts: 64
Thanks: 9
Killswitch is on a distinguished road
Default

I have done this using numerous methods. The most simple for me was to simply define or in the case of a forum, create a friendly url value out of the title. In my CMS' I do the same only the administrator can define one, if not defined, create from the title.

Either way, my current CMS is MVC based, so it has been quite simple to do. For example, site.com/content/index/php would really be a call to the content.php controller, calling the index() method and passing php as a parameter.

I would then show the page that matches php as the URL value (ofcoarse upon creating, editing, etc pages I ensure I can't have conflicting results, many of the same, etc). Further more I can go another step to have site.com/content/index/php/strlen.

This is the same, but php AND strlen is passed to the index() method. If I find I have the second parameter, I will attempt to load the child based on the parent being PHP.

I know, sounds confusing but its not. You could do similar things using $_GET alone, but you will need more mod_rewrite rules to match. For example, in an older CMS I wrote before finding MVC, I used to have a component based setup. Basically, I requested an action ( $_GET['action'] ) which was used to determine the component file. If the action was content, then I would load content.php.

From here the component decided what to do, usually in the constructor or a secondary method (using switch to check for a $_GET['whatever_else']). Using that value would determine the method called, and for additional parameters I would simply call $_GET again. MVC made this MUCH, MUCH easier (you can check out Kohana Framework, Code Ignitor or MVC design patterns with PHP).

In your case, or in VB, I don't know how they do it. I've made a forum in which you would have urls such as site.com/forum/general/how-do-i-do-this.html. Again, the same principal. general is a value stored in the database under a URL field. how-do-i-do-this is a value stored in the database as well, but the topics have a forum_url field to match to ensure that the how-do-i-do-this page belongs with general.

Sorry, might sound confusing, but it's not that bad if you play with it. If you need, I can show off my database schema for the CMS/forum I am writing and it will probably click much better.
Killswitch is offline  
Reply With Quote
Reply



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
vB related - rep points for threads? Brook General 1 02-22-2008 02:21 PM
Any coders here use Drupal and vB? (Or have been thinking about it?)) Brook General 0 01-30-2008 04:01 AM
Different style template system? Nor General 2 01-15-2008 01:10 PM
Creating a vB plug-in Brook Absolute Beginners 0 12-16-2007 05:44 PM


All times are GMT. The time now is 10:46 PM.

 
     

Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0
Inactive Reminders By Icora Web Design