Welcome Guest, Not a member yet? Register   Sign In
Building a CMS: Best Way To Handle Categories and Page Names In URL?
#9

[eluser]Phil Sturgeon[/eluser]
@Wired: When I saw that snippet I hoped I just overlooked something, but that does not do the same job.

Code:
echo "<pre>";
    $segments = array('one', 'two');
        switch (count($segments))
        {
            case 3:
                list($cat, $subcat, $page_name) = $segments;
            break;

            case 2:
                list($cat, $page_name) = $segments;
                $subcat = NULL;
            break;

            default:
                list($page_name) = $segments;
                $cat = $subcat = NULL;
            break;
        }

list($cat2, $subcat2, $page_name2) = array_pad($segments, 3, NULL);

var_dump($cat === $cat2, $subcat === $subcat2, $page_name === $page_name2);

If 3 segments there is a category and a page. If 3 there is a sub category too. If only 1 then there is a page.

This is not how I would implement cats and pages, but this is what the original poster wanted.


Messages In This Thread
Building a CMS: Best Way To Handle Categories and Page Names In URL? - by El Forum - 02-28-2011, 04:36 PM



Theme © iAndrew 2016 - Forum software by © MyBB