4images Forum & Community

4images Modifications / Modifikationen => Mods & Plugins (Requests & Discussions) => Topic started by: adrianus on August 07, 2007, 06:27:45 PM

Title: How to change description and keywords META TAG in header
Post by: adrianus on August 07, 2007, 06:27:45 PM
I've seen that some of you are getting personalized header in each page, with different description and keywords meta tag.
How can i do that? Is there a mod for this kind of SEO need?
I'd like to have at least a description tag with trunked description get from image or category description.

Please help me!   :oops:

AD
Title: Re: How to change description and keywords META TAG in header
Post by: gino on November 19, 2007, 06:30:25 AM
STUPID ME FORGOT THAT YOU CANT SEE THE BOLD SO PLEASE LOOK AT THE CODE INBETWEEN THE [ b ] and the [ / b ]....that is where the bold was

I will try to help you.  I just downloaded this today and this is the first time looking at the code so there is a simpler way but i dont have time to learn all the code that is in this script and find where the proper code should go.  Basically the easiest way is to duplicate your templates.  Really this is not as hard as you think.  All the information you will need to input into your meta tags are already in your data base you just need to fetch them.  Now the reason why we are going to duplicate them(This is the short cut) is your using two different files to display your website...well at least most of the pages.  There is the main one and the detailed page.  You are going to want to seperate these so you get the max out of the spider that will crawl your page.  Now again this is not really the way to do it but it will work...just not with your rating page and top page ect....if you want to see an example go to peterl.ca (http://peterl.ca)...just dont tell my father in law as it is his website :P

First we are going to need to change your meta tages so open up your template/default/header.html
change all the bold spots
Code:  [Select]  [Expand]
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html dir="{direction}">
<head>
<title>{site_name} - {cat_name}</title>
<meta http-equiv="content-type" content="text/html; iso-8859-1">
<meta name="robots" content="INDEX,FOLLOW">
<meta http-equiv="content-language" content="en">
<meta name="description" content="{cat_description}.">
<meta name="keywords" content="{cat_name} {site_name}">
<meta name="author" content="Laagee Web Design">
<meta name="revisit-after" content="10 days">
<meta http-equiv="imagetoolbar" content="no">
<meta http-equiv="content-type" content="text/html; charset={charset}" />
<link rel="stylesheet" href="{template_url}/style.css" />

<script language="javascript" type="text/javascript">
<!--

This will automatically change your site to the input in your data base.  Now because we have the detail.php for your pictures this type of meta tag will not due.  Cause it will show the category it is in and your site name for the metas.  So we need to change this part.  This is where it might get complicated so try to follow along.

First we need to start at the source. details.php.  again change the bold spots
Code:  [Select]  [Expand]
$main_template = 'details';

define('GET_CACHES', 1);
define('ROOT_PATH', './');
include(ROOT_PATH.'detail_global.php');
require(ROOT_PATH.'includes/sessions.php');
$user_access = get_permission();
include(ROOT_PATH.'includes/header.php');

if (!$image_id) {
    redirect($url);

Now in your script there is no detailed_global.php  so what we need to do is copy the whole file of global.php and paste it into a blank file and call it detail_global.php.  DO NOT DELETE THE GLOBAL.PHP you still need it!
when your done copy and pasting find the line.
Code: [Select]
include_once(ROOT_PATH.'includes/template.php');Change it to
Code: [Select]
include_once(ROOT_PATH.'includes/detail_template.php');
Now again there is no file called detailed_template.php...so you need to open up your file template.php and like before copy all the contents and name it detail_template.php.
Close to the end of the file you will find this code
Code: [Select]
function print_template($template) {
    if (strpos($template, $this->start.'header'.$this->end) !== false) {
      $header = $this->parse_template("header");
      $template = str_replace($this->start.'header'.$this->end, $header, $template);
    }
Change all the bold lines
Code:  [Select]  [Expand]
function print_template($template) {
    if (strpos($template, $this->start.'detail_header'.$this->end) !== false) {
      $header = $this->parse_template("detail_header");
      $template = str_replace($this->start.'detail_header'.$this->end, $header, $template);
    }
Almost done...now we need to create the detail_header.html.  So go into templates/default/header.html  copy it all and paste it again and name it detail_header.html.  after that you will need to change all the red lines here
Code:  [Select]  [Expand]
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html dir="{direction}">
<head>
<title>{site_name} - {image_name}</title>
<meta http-equiv="content-type" content="text/html; iso-8859-1">
<meta name="robots" content="INDEX,FOLLOW">
<meta http-equiv="content-language" content="en">
<meta name="description" content="{image_description}.">
<meta name="keywords" content="{image_name} {site_name}">
<meta name="author" content="Laagee Web Design">
<meta name="revisit-after" content="10 days">
<meta http-equiv="imagetoolbar" content="no">
<meta http-equiv="content-type" content="text/html; charset={charset}" />
<link rel="stylesheet" href="{template_url}/style.css" />

<script language="javascript" type="text/javascript">
<!--

One more thing and we are done.  Open up templates/default/details.html at the very top it will say {header}  change this to {detail_header} and your done.  You will have a site like this http://www.peterl.ca (http://www.peterl.ca)  All the pages have there own unique tags.  I hope this has helped.  And for all the people that actually know this script please post a better way of doing this cause for the guys that dont really know what they are doing it could really help them....CHEERS!
Title: Re: How to change description and keywords META TAG in header
Post by: rinaldos on November 21, 2007, 09:20:42 PM
Hi,
this works, but I changed some of your steps.

First I use the TWEAK from Thunderstrike:
    
[TWEAK] Universal layout - HTML template tags  (http://www.4homepages.de/forum/index.php?topic=18926.0)

My first Step was to change /includes/templates.php

find
Code: [Select]
function print_template($template) {
if (strpos($template, $this->start.'header'.$this->end) !== false) {
      $header = $this->parse_template("layout/header");
      $template = str_replace($this->start.'header'.$this->end, $header, $template);
    }

and add after with:
Code: [Select]
if (strpos($template, $this->start.'header_detail'.$this->end) !== false) {
      $header = $this->parse_template("layout/header_detail");
      $template = str_replace($this->start.'header_detail'.$this->end, $header, $template);
    }

The i copied my /templates/default/layout/header.html to /templates/default/layout/header_detail.html

I replaced the META Tags
Code: [Select]
<title>{site_name} - {image_name}</title>
{redirect}
<meta http-equiv="content-type" content="text/html; iso-8859-1">
<meta name="robots" content="INDEX,FOLLOW">
<meta http-equiv="content-language" content="en">
<meta name="description" content="{image_description}.">
<meta name="keywords" content="{image_name} {site_name}">
<meta name="author" content="Rinaldos-World">
<meta name="revisit-after" content="10 days">
<meta http-equiv="imagetoolbar" content="no">
<meta http-equiv="content-type" content="text/html; charset={charset}" />

and now edit /templates/default/details.html

find:
Code: [Select]
{header}

replace with
Code: [Select]
{header_detail}

And it works also :-)

Thanks for your wonderfull MOD :-)

Gruß
Ingo
Title: Re: How to change description and keywords META TAG in header
Post by: thunderstrike on November 21, 2007, 10:03:10 PM
Very good - is purfect way for edit template. ;)
Title: Re: How to change description and keywords META TAG in header
Post by: jojomart on January 10, 2008, 09:42:45 PM
I love love love this mod!

Isn't there someway that for the meta keywords, we can use {image_keywords} instead of {image_name} {site_name} and not have them show on the actual top of the page as links?

Look forward to your help!

Joanne
Title: Re: How to change description and keywords META TAG in header
Post by: jojomart on January 12, 2008, 03:32:30 AM
I don't know if it's something I did wrong (don't think so though), but on my home page, the title is always wrong - it really shouldn't be pointing to a certain category but it does (games - only Good Lord knows why LOL) and then the keywords are from a different category!

Is there some way of making the header for just the main page be keywords that I can actually type in, and then the other pages use the keyword templates?

thanks,

Joanne
Title: Re: How to change description and keywords META TAG in header
Post by: Anarchology on January 03, 2009, 08:46:52 AM
Hi,

I had a couple problems integrating this MOD to 1.7.6. I can see this MOD is over a year old, and wondering if there need to be any other needed modifications to certain files? I'll keep trying at it. If I get the error the second time I try it, I'll modify this post and post it up. I'm talking about the main mod posted by member gino.

Thanks in advance

EDIT: This is the error I am getting..
Code: [Select]
Parse error: syntax error, unexpected '[' in /home/site_login/public_html/details.php on line 29
Title: Re: How to change description and keywords META TAG in header
Post by: om6acw on January 03, 2009, 06:47:55 PM
its working for me and Im using 176 version of 4image
Title: Re: How to change description and keywords META TAG in header
Post by: V@no on January 03, 2009, 07:14:37 PM
EDIT: This is the error I am getting..
Code: [Select]
Parse error: syntax error, unexpected '[' in /home/site_login/public_html/details.php on line 29
STUPID ME FORGOT THAT YOU CANT SEE THE BOLD SO PLEASE LOOK AT THE CODE INBETWEEN THE [ b ] and the [ / b ]....that is where the bold was


Anyway, I've update the post, it displays properly now.
Title: Re: How to change description and keywords META TAG in header
Post by: om6acw on January 03, 2009, 07:31:15 PM
would be nice find out how to use {image_keywords} in header with out links just in plain text format.

Quote
<meta name="keywords" content="{image_keywords}">
Title: Re: How to change description and keywords META TAG in header
Post by: V@no on January 03, 2009, 07:39:13 PM
in includes/functions.php find:
Code: [Select]
    "image_keywords" => $keywords,
Insert below:
Code: [Select]
    "image_keywords2" => str_replace(" ", ",", $image_row['image_keywords']),
Title: Re: How to change description and keywords META TAG in header
Post by: om6acw on January 03, 2009, 08:06:30 PM
Thanks V@ano,
just now with your code this mode its ideal and fully functional.
Thanks a lot!!!
Title: Re: How to change description and keywords META TAG in header
Post by: Anarchology on January 04, 2009, 12:23:03 AM
Anyway, I've update the post, it displays properly now.

Ahhh, I'm guessing that there were bold tags accidentally within the coding? I'm going to try this again tonight and post up any errors if I get any. Hopefully this helps me out.

Thanks for the help!

- A
Title: Re: How to change description and keywords META TAG in header
Post by: J.Lond on January 12, 2009, 05:21:05 AM
This method works just as well.  Just create a new header for category and details templates.

http://www.4homepages.de/forum/index.php?topic=15603.0


Best Regards
Title: Re: How to change description and keywords META TAG in header
Post by: KurtW on January 12, 2009, 05:59:32 AM
Hi,

why so mutch work for a new details_header.html  8O

copy your changed code from header.html
and replace in details.html
Code: [Select]
{header}with this code.

Now you can use in details.html all image tags...
Finish...
OK, only the changed code in includes/functions.php is also requiered  :wink:

The same in categories.html and all other templates, if you need different metas


Kurt
Title: Re: How to change description and keywords META TAG in header
Post by: Anarchology on January 29, 2009, 04:59:52 AM
Hey guys,

I have a quick question for you. I'm having just a little bit of an issue with this MOD. It isn't anything major, but wondering how this is happening and what I can do to prevent it. When viewing my main page, my site name is shown (what I want), but it is followed by the last category where an image was uploaded to. Oddly, this even happens when that certain category is hidden to guests.

Basically, it isn't the best thing for my site to have be called "My Site - XXX Pix" if you catch my drift.  :?

How can I modify the code so that when viewing my main page (home page) that ONLY my site's name is shown?

Thanks in advance!
Title: Re: How to change description and keywords META TAG in header
Post by: spookypld on February 04, 2009, 11:55:26 AM
For Details page You need only to paste in header.html this code:

Quote
<meta name="description" content="{image_description}">


Problem is that with allowed meta-tags in image description it copies HTML takgs f.e.
Quote
<br />
and it doesn't work for the rest of the page.
Title: Re: How to change description and keywords META TAG in header
Post by: relu on February 14, 2009, 02:17:27 AM
in includes/functions.php find:
Code: [Select]
    "image_keywords" => $keywords,
Insert below:
Code: [Select]
    "image_keywords2" => str_replace(" ", ",", $image_row['image_keywords']),

This is verry useful for meta tag keywords.  Also i have in mind to add a new field for tag description in acp next to image name description and keywords. After to add it in meta tag keywords. Is almost the same thing but i think is usefull for a good seo. For Category is also will be a good thing to can add some keywords for  category pages. You thing is complicated?
Title: Re: How to change description and keywords META TAG in header
Post by: AntiNSA2 on May 17, 2009, 09:27:13 PM
in includes/functions.php find:
Code: [Select]
    "image_keywords" => $keywords,
Insert below:
Code: [Select]
    "image_keywords2" => str_replace(" ", ",", $image_row['image_keywords']),

Are you saying instead of doing the steps that he mentioned in the beginning of this thread, instead just add the code you mentioned here and that is all you need to do?
Title: Re: How to change description and keywords META TAG in header
Post by: webpit on November 07, 2011, 02:54:50 AM
... just for your info...
pls be aware of using html code at description..
when you use
<meta name="description" content="{image_description}."> at header .. so better avoid using (") tag.. otherwise, it will be some messy-word displayed at the top of your page ..  :)
.. you can use (') tag.. for example if you put external link <a href='http:// .... '></a>
or if you already have (") tag in all your description.. you can change at the header vise versa..:
<meta name="description" content='{image_description}.'>

hopefully useful .. :)

rgds,
if you interesting in Indonesia wayang .. you can visit my site http://galeri.wayang.pitoyo.com