Welcome to Geeklog, Anonymous Wednesday, November 13 2024 @ 01:10 pm EST

Geeklog Forums

Adding dynamic meta data to stories

Page navigation


Status: offline

ByteEnable

Forum User
Full Member
Registered: 10/20/03
Posts: 138
Insert two rows into your gl_stories table of your geeklog database:
"meta_description" with a type of text, NULL
"meta_keywords" with a type of text, NULL

config.php, add:
Text Formatted Code

$_CONF['meta_description'] = "The coolest website ever!";
$_CONF['meta_keywords'] = "my,keywords,rank,high,in,google";


 

header.thtml, add the following somewhere in the "head":
Text Formatted Code

<META NAME="description" CONTENT="{meta_description}">
<META NAME="keywords" CONTENT="{meta_keywords}">

 

storyeditor.thtml, add the following above intro_text:
Text Formatted Code

<tr>
  <td valign="top" align="right">Meta Desc:</td>
  <td><textarea name="meta_description" cols="60" rows="2">{story_meta_description}</textarea></td>
</tr>
<tr>
  <td valign="top" align="right">Meta Keywords:</td>
  <td><textarea name="meta_keywords" cols="60" rows="2">{story_meta_keywords}</textarea></td>
</tr>


 

article.php, modify the COM_siteHeader (around line 150) function call:
Text Formatted Code

$display .= COM_siteHeader ('menu', $pagetitle, $rdf,$A['meta_description'],$A['meta_keywords']);


 

lib-common.php, modify the COM_siteHeader function:
Text Formatted Code

function COM_siteHeader( $what = 'menu', $pagetitle = '', $headercode = '',$meta_desc='',$meta_key='')

around line 579 or so add:

if ( !empty($meta_desc))
  $_CONF['meta_description'] = $meta_desc;
if ( !empty($meta_key))
  $_CONF['meta_keywords'] = $meta_key;
$header->set_var(meta_description,$_CONF['meta_description']);
$header->set_var(meta_keywords,$_CONF['meta_keywords']);


 

story.php, add the following around 579:
Text Formatted Code

$story_templates->set_var('story_meta_description',$A['meta_description']);
$story_templates->set_var('story_meta_keywords',$A['meta_keywords']);

modify the submitstory function with meta data:

function submitstory($type='',$sid,$uid,$tid,$title,$introtext,$bodytext,$hits,$unixdate,$expiredate,$comments,$featured,$commentcode,$trackbackcode,$statuscode,$postmode,$frontpage,$draft_flag,$numemails,$owner_id,$group_id,$perm_owner,$perm_group,$perm_members,$perm_anon,$delete,$show_topic_icon,$meta_description,$meta_keywords,$old_sid)

just before the DB_save call in function submitstory add:
$meta_description = addslashes($meta_description);

Modify the DB_save with the meta data:
DB_save ($_TABLES['stories'],'sid,uid,tid,title,introtext,bodytext,hits,date,comments,related,featured,commentcode,
trackbackcode,statuscode,expire,postmode,frontpage,draft_flag,numemails,owner_id,group_id,perm_owner,
perm_group,perm_members,perm_anon,show_topic_icon,in_transit,meta_description,meta_keywords', "'$sid',$uid,'$tid','$title','$introtext','$bodytext',$hits,FROM_UNIXTIME($unixdate),'$comments','$related',$featured,'$commentcode','$trackbackcode','$statuscode',FROM_UNIXTIME($expiredate),'$postmode','$frontpage',$draft_flag,$numemails,$owner_id,$group_id,$perm_owner,$perm_group,$perm_members,$perm_anon,$show_topic_icon,1,'$meta_description','$meta_keywords'");

around line 1100 or so add the meta data:
COM_applyFilter ($_POST['show_topic_icon']), <- dont add this

COM_stripslashes ($_POST['meta_description']),
COM_stripslashes ($_POST['meta_keywords']),

COM_applyFilter ($_POST['old_sid'])); <- dont add this


 
 Quote

Jesse

Anonymous
Great hack! I am looking for this.

----------
Solidot.org - China Slashdot Site Powered by Geeklog
 Quote

Status: offline

joshtravis

Forum User
Newbie
Registered: 10/05/05
Posts: 6
Location:Brighton TN
I think this should be default behavior for new releases of Geeklog.
 Quote

Status: offline

beewee

Forum User
Full Member
Registered: 08/05/03
Posts: 969
Location:The Netherlands, where else?
Quote by joshtravis: I think this should be default behavior for new releases of Geeklog.


Yep, but also in another way: display the keywords as 'tags'. An alternative for posting to multiple topics I guess. How can I display the keywords the way Technorati etc like it in my story? See this:

Text Formatted Code
<a href="http://technorati.com/tag/[tagname]" rel="tag">[tagname]</a>
 

Dutch Geeklog sites about camping/hiking:
www.kampeerzaken.nl | www.campersite.nl | www.caravans.nl | www.caravans.net
 Quote

Status: offline

bjudson

Forum User
Junior
Registered: 01/01/04
Posts: 34
Adding the dynamic tags like sotry keywords and such make sense to do with code;
but a field should exist either in the config file, or in the database to add SOMETHING to all templates area.

An example that I always use is GeoURL:
Text Formatted Code
<meta name="ICBM" content="49.13481, -102.99079" />
<meta name="DC.title" content="Ben And Amys Place" />
<meta anything .... />
<meta more .... />
<script type=anything>

 
Even with one "HEAD" field to edit you could add your GEO URL, meta_descriptions, meta_keywords, even custom javascript to spam-proof email addresses etc.

This solution seems more scalable than the original cool_hack.

 Quote

Status: offline

drshakagee

Forum User
Full Member
Registered: 10/01/03
Posts: 231
Quote by bjudson:but a field should exist either in the config file, or in the database to add SOMETHING to all templates area.



If your meta data isn't dynamic why not just add it to your header.thtml file?
Yes I am mental.
 Quote

Status: offline

Dirk

Site Admin
Admin
Registered: 01/12/02
Posts: 13073
Location:Stuttgart, Germany
Technorati-style tags can be implemented as a plugin.

bye, Dirk
 Quote

Status: offline

beewee

Forum User
Full Member
Registered: 08/05/03
Posts: 969
Location:The Netherlands, where else?
That's all. This is a plugin (you have to create the entry in the
plugins table yourself, then safe it as plugins/tags/functions.inc)
which provides a [tag:] autotag. Now just insert the tags somewhere in
the text and it will collect them and list them at the end of the text.


So if i write a story about swimming in Miami I would have to write it like this:

I love [tag: swimming] in [tag:Miami].

Am I correct?

And, since I'm no developer, is somebody interested in making it a normal plugin? Making new templates should not be necessairy, if there is a {} tag we can put in the story and header template somewhere.
Dutch Geeklog sites about camping/hiking:
www.kampeerzaken.nl | www.campersite.nl | www.caravans.nl | www.caravans.net
 Quote

Status: offline

bjudson

Forum User
Junior
Registered: 01/01/04
Posts: 34
Quote by drshakagee:
Quote by bjudson:but a field should exist either in the config file, or in the database to add SOMETHING to all templates area.



If your meta data isn't dynamic why not just add it to your header.thtml file?


The only reason I would do it at the core is so it would affect all templates. Users could download other templates, and not worry about having to modify them all the time.

Further functionality, like the new editor could use this functionality as well. Why call it with a plugin API, if the functionality is used at the core of serving pages? It's just extra overhead.

-Ben

 Quote

Status: offline

1000ideen

Forum User
Full Member
Registered: 08/04/03
Posts: 1298
Yes, I think the idea of flexible meta data is great. Though one should consider some more fields like this and maybe 1-3 open fields to be defined somewhere:

Text Formatted Code

<meta name="language" content="??">
<meta name="topic" lang="??" content="??">
<meta name="type" lang="??" content="??">
<meta name="audience" lang="??" content="??">
<meta name="description" lang="??" content="??">
<meta name="keywords" lang="??" content="??">


 
 Quote

Raven

Anonymous
Hello,

Two questions about this.

(1) Will it still work with current version of geeklog? No issues?

(2) How about for my index page, how do I get the meta dialog to appear there?
 Quote

Status: offline

ByteEnable

Forum User
Full Member
Registered: 10/20/03
Posts: 138
Quote by Raven:
(1) Will it still work with current version of geeklog? No issues?

Yeah

Quote by Raven:
(2) How about for my index page, how do I get the meta dialog to appear there?


All pages will display the meta data, its in the header. For index pages and such it will display the default data that you have defined in config.php
 Quote

Status: offline

Spirit_of_Martin

Forum User
Newbie
Registered: 07/28/05
Posts: 7
Hello

When i add meta to article, with this hack, then save it i got a error:

Text Formatted Code
Warning: Missing argument 30 for submitstory() in /public_html/admin/story.php on line 919

Warning: Illegal offset type in /system/lib-security.php on line 191

 


My geek is 1.3.11sr5

Any sugestion?? Question
www.malach.org
 Quote

Status: offline

Robin

Forum User
Full Member
Registered: 02/15/02
Posts: 725
confused
Something ain't right with this hack.
I introduced all the changes, hack seems to work as I can add meta desc and keywords and they are actually saved in the db. However when you click on a story and then look into the source there is nothing there, expcept for the meta data from config.

GL 1.4.0sr2

Any help much appreciated
Geeklog Polish Support Team
 Quote

Status: offline

Robin

Forum User
Full Member
Registered: 02/15/02
Posts: 725
working
I suspect that the problem is with lib-common.php part.

Could you please post the piece of code from lib-common with this additional code? Where does it go exactly?

Thanks Smile

Robert
Geeklog Polish Support Team
 Quote

ys

Anonymous
want solutions too!
 Quote

Status: offline

Robin

Forum User
Full Member
Registered: 02/15/02
Posts: 725
Could someone please confirm that this hack actually works works on 1.4.0. ?
TIA Its a deal - shaking hands
Geeklog Polish Support Team
 Quote

Raven

Anonymous
Bump for last response
 Quote

GGGGG

Anonymous
Quote by Robin: Something ain't right with this hack.
I introduced all the changes, hack seems to work as I can add meta desc and keywords and they are actually saved in the db. However when you click on a story and then look into the source there is nothing there, expcept for the meta data from config.

GL 1.4.0sr2

Any help much appreciated


Bump, having same problem, any solutions? Smile
 Quote

Status: offline

Scotsman

Forum User
Newbie
Registered: 06/23/02
Posts: 14
for lib-common.php where it says around line 579, instead place it at about line 975. I placed it after $charset = $LANG_CHARSET; and works fine.
 Quote

Page navigation

All times are EST. The time is now 01:10 pm.

  • Normal Topic
  • Sticky Topic
  • Locked Topic
  • New Post
  • Sticky Topic W/ New Post
  • Locked Topic W/ New Post
  •  View Anonymous Posts
  •  Able to post
  •  Filtered HTML Allowed
  •  Censored Content