Forums / General Questions / Defining with an * or Wild Card

Defining with an * or Wild Card

Locked

Views: 1,150

Results 1 to 6 of 6
This thread is locked. New replies are disabled.
9 Apr 2009, 4:45 PM
#1
bumba000 avatar

bumba000

Totally Zenned

Join Date:
Feb 2007
Location:
Pennsylvania
Posts:
859
Plugin Contributions:
0

Defining with an * or Wild Card

Hi all,
Getting some custom defines worked out here and need a bit of guidance. Here is what I would like to do:

define('META_TAG_TITLE_/WOZ/TAG/*', 'Here is the Meta Title Text!');

So that no matter what "tag" is being viewed this is the title that will be used. Apparently the * is not what I need to use here.

Thanks in Advance,
John

9 Apr 2009, 5:07 PM
#2
gjh42 avatar

gjh42

Black Belt

Join Date:
Jul 2005
Location:
Upstate NY
Posts:
21,876
Plugin Contributions:
8

Re: Defining with an * or Wild Card

You need to have essentially a separate define statement for each tag. Are you saying you want to have the same meta title for all of them?

You can either just make a list of all of the defines for all cases, or if you have a variable/array that holds all of the tags you are going to want, you can loop through the array and substitute the current value into the define.```php
foreach ($tag_array as $tag_value){
define('META_TAG_TITLE_/WOZ/TAG/' . $tag_value, 'Here is the Meta Title Text!');
}

9 Apr 2009, 5:27 PM
#3
bumba000 avatar

bumba000

Totally Zenned

Join Date:
Feb 2007
Location:
Pennsylvania
Posts:
859
Plugin Contributions:
0

Re: Defining with an * or Wild Card

Hi Glenn,
Thanks for the quick help!

This is not exactly what I'm looking for here. I have written / compiled custom code that allows us to use custom meta info for every page, post, category. . . for WOZ.

This is being done with an overridden html_header.php, languages/meta_tags.php and modules meta_tags.php.

This is how I'm determining what wp page we're on

require(DIR_WS_LANGUAGES . 'english/MyTemp/wp_meta_tags.php'); 
function curPageURL() { 
 $pageURL = $_SERVER["REQUEST_URI"];
 return $pageURL;
  } 
    $wpPageBase = curPageURL();
   // echo strtoupper($wpPageBase);

// if per-page metatags overrides have been defined, use those, otherwise use usual defaults:

  if (defined('META_TAG_TITLE_' . strtoupper($wpPageBase))) define('META_TAG_TITLE', constant('META_TAG_TITLE_' . strtoupper($wpPageBase)));
  
   if (defined('META_TAG_KEYWORDS_' . strtoupper($wpPageBase))) define('META_TAG_KEYWORDS', constant('META_TAG_KEYWORDS_' . strtoupper($wpPageBase)));
  
  if (defined('META_TAG_DESCRIPTION_' . strtoupper($wpPageBase))) define('META_TAG_DESCRIPTION', constant('META_TAG_DESCRIPTION_' . strtoupper($wpPageBase)));
```the entire address after <http://www.mydomain.com/> is being stored in $wpPageBase. so if I echo this out on screen on a "tags" page I would see /WORDPRESS/TAG/THE-TAG-NAME/

So if we can say something like define('META_TAG_TITLE_/WORDPRESS/TAG/* 

and have that title define used for any /WORDPRESS/TAG/ this would complete the customization.
9 Apr 2009, 5:37 PM
#4
gjh42 avatar

gjh42

Black Belt

Join Date:
Jul 2005
Location:
Upstate NY
Posts:
21,876
Plugin Contributions:
8

Re: Defining with an * or Wild Card

You will have to get the value of the tag name into the define - a * is just not going to work.

If you have the address including the tag name stored in $wpPageBase, you can use PHP string functions to extract the part you want, put it into a variable, and use that variable in the define (just llike the example above, without the foreach loop).
Gotta run, can't do more now.

9 Apr 2009, 6:25 PM
#5
bumba000 avatar

bumba000

Totally Zenned

Join Date:
Feb 2007
Location:
Pennsylvania
Posts:
859
Plugin Contributions:
0

Re: Defining with an * or Wild Card

Thanks again Glenn!

I can not believe how well my php is coming along. Thank you for the pointer.

Here is what I have concocted. Of course there is a set of matching defines in the language file!

<?php
/**
 * meta_tags module
 *
 * @package modules
 * @copyright Copyright 2003-2007 Zen Cart Development Team
 * @copyright Portions Copyright 2003 osCommerce
 * @license http://www.zen-cart.com/license/2_0.txt GNU Public License V2.0
 * @version $Id: meta_tags.php 6863 2007-08-27 16:06:25Z drbyte $
 */
if (!defined('IS_ADMIN_FLAG')) {
  die('Illegal Access');
}
// This should be first line of the script:
require(DIR_WS_LANGUAGES . 'english/MyTemp/wp_meta_tags.php'); 
function curPageURL() { 
 $pageURL = $_SERVER["REQUEST_URI"];
 return $pageURL;
  } 
    $wpPageBase = curPageURL();
    $wpTag = substr($wpPageBase,0,15);

    //echo strtoupper($wpTag);

// if per-page metatags overrides have been defined, use those, otherwise use usual defaults:
if (strtoupper($wpTag) == '/WORDPRESS/TAG/') {
if (defined('META_TAG_TITLE_/WORDPRESS/TAG/')) define('META_TAG_TITLE', constant('META_TAG_TITLE_/WORDPRESS/TAG/'));
if (defined('META_TAG_KEYWORDS_/WORDPRESS/TAG/')) define('META_TAG_KEYWORDS', constant('META_TAG_TITLE_/WORDPRESS/TAG/'));
if (defined('META_TAG_DESCRIPTION_/WORDPRESS/TAG/')) define('META_TAG_DESCRIPTION', constant('META_TAG_TITLE_/WORDPRESS/TAG/'));
  } else {
  if (defined('META_TAG_TITLE_' . strtoupper($wpPageBase))) define('META_TAG_TITLE', constant('META_TAG_TITLE_' . strtoupper($wpPageBase)));
  
   if (defined('META_TAG_KEYWORDS_' . strtoupper($wpPageBase))) define('META_TAG_KEYWORDS', constant('META_TAG_KEYWORDS_' . strtoupper($wpPageBase)));
  
  if (defined('META_TAG_DESCRIPTION_' . strtoupper($wpPageBase))) define('META_TAG_DESCRIPTION', constant('META_TAG_DESCRIPTION_' . strtoupper($wpPageBase)));
  };
```Coder For Hire Here!! Kidding LOL

Thanks again Glenn,
                             John