Jump to content

Recommended Posts

Hey All,

 

I am sure there is a smarter way of doing this...

Basically I have a file called control.php, and it contains a case.

 

for example on my index.php

 

I set a variable $sheet_name = "homepage"

and include my control.php

 

So every page on my site has "sheet name" I call it and set the other variables.  Reason I'm doing this is for quick editing for SEO, so I can edit titles and description and keywords for all my pages from one file.  I also set variables for different "categories" so I can highlight my navigation to show current page with a style if the category = "whatever"

 

	case 'homepage':
{
	$page_id = "1";
	$title ="Page Title";
	$meta_desc = "Page Description";
	$meta_key = "keywords";
	$category = "keywords";
	  include("inc/head.php");
	  include("inc/header1.php");
	break; 
}

 

basically, Is this at all a smart way of doing this or should I move to storing variables in a database and then calling them?  Or continue with how I have it.

If it is only you updating then it may aswell be in a static file unless you start to add many more pages then a database is the best bet. If static I think I would have used an array with the page id as the key:

<?php

$pages[1] = array('title' => 'home', 'meta_key' => '', 'meta_desc' => '');
$pages[2] = array('title' => 'about', 'meta_key' => '', 'meta_desc' => '');
$pages[3] = array('title' => 'contact us', 'meta_key' => '', 'meta_desc' => '');

// get page details - if page_id parameter is not set or invalid then set to 1	
$thisPage = $pages[(array_key_exists($_GET['page_id'], $pages) ? $_GET['page_id'] : 1)];
print $thisPage['title'];
?>

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.