Gossamer Forum
Home : Products : Gossamer Links : Discussions :

Adding Additional globals like <%meta_name%>

Quote Reply
Adding Additional globals like <%meta_name%>
Afternoon,
been searching about and haven't found anything like this. What i'm after is the ability to add additional globals such as <%meta_name%> / <%meta_keywords%> etc, so that under browse > category, theres additional form parts there which i can use to set globals there. Then on the template I can use <%new_global%> on a per category basis. (Exactly the same as <%meta_keywords%>, just additional ones).

Any ideas how this can be done?

Cheers.
Quote Reply
Re: [ryanbigmedia] Adding Additional globals like <%meta_name%> In reply to
Not quite certain I understand - but I don't think you want new globals, you just need to add columns to your Category table. Go to admin->Database->Category->properties and you should be able to add columns. See the documentation for more information about how to do this.
Quote Reply
Re: [afinlr] Adding Additional globals like <%meta_name%> In reply to
hiya,
This would also create a lot more additional work through wouldn't it? as with modifying the database, as well as modifying the admin section to display and insert etc into the right fields and all that.

I was after something a bit more faster to do on the fly, rather than modifying a far chunk of links sql it self.

---

I'm also having a problem with the <%meta_name%> tag not carrying it self down to the bottom category, I was under the impression that what ever is set in the top level category, this would be the same all the way down unless otherwise changed.

i.e: meta description on Anglia would be the same on Plymouth, if it isn't changed on plymouth.

Is there anyway to do this? or an easier way to duplicate that out only categories specified?

Cheers.
Quote Reply
Re: [ryanbigmedia] Adding Additional globals like <%meta_name%> In reply to
Hi,

If you want some specific text which changes with each category then I can assure you that the easiest way to do this is to add a column to your category table. This isn't changing chunks of links sql itself - the ability to add columns to tables is an important aspect of the software - the columns automatically get added to the admin interface.

As for the meta_name tag - this is category specific - it doesn't get passed down to sub categories. You could use a global to pull the meta_name from the top category or you could populate your sub categories using a mysql command (actually I think it would take a command for each top level category so it depends how many you have - this may be impractical).
Quote Reply
Re: [afinlr] Adding Additional globals like <%meta_name%> In reply to
hiya,
Yer thats what were after, some specific text that is effectively editable via the admin section so that it can be changed ont he fly, using just one single template, rather than building a few hundred for some minor changes on the different categorys.

Do you have any information on adding columns so that it does show on the admin section of the category part? can do it on the database but not sure if i have to do anything else. Or doing it in a specific way.

As for the meta_name tag, thats a shame, we really needed it to get passed down unless changed, idealy, we would like to add additional meta_name type of tags to make things easier on minor changes.

Do you have any information on doing the globals to make this happen? there is a lot of categorys, stretching down by aprox 50 subs per main top category. It is only the top level category that needs the changes, through it would be nice to specify some of the lower level categories when needed for a change.

Not sure where to start on this through.

Cheers.
Quote Reply
Re: [ryanbigmedia] Adding Additional globals like <%meta_name%> In reply to
You can either add columns directly into the database, for example using mysqlman, or in admin->database->Category->properties. In the first case you can add the column wherever you like in the table but you will need to go to admin->database->Category->properties and resync the database to get the column to appear in admin. In the second case the column will automatically appear in admin but you will only be able to add the column at the end of the table.

As for the global something like this should work:

sub {
my $tags=shift;
if ($tags->{meta_name}){return;}
my $name=$tags->{Full_Name};
$name=~s,^([^/]+).*,$1,;
my $db = $DB->table('Category');
my $meta = $db->select('Meta_Description',{Full_Name=>$name})->fetchrow_array;
return $meta;
}
Quote Reply
Re: [afinlr] Adding Additional globals like <%meta_name%> In reply to
hiya, ta for reply,
I've been trying to find information on how to add globals such as the above but came up empty, keep hearing about globals.txt, but cant see anything in there that would acturally be a globals file.

Mind doing a run down on how to do the globals side of things?

Cheers.
Quote Reply
Re: [ryanbigmedia] Adding Additional globals like <%meta_name%> In reply to
Sure Wink.

Just go to your admin panel and click on 'Build' and then 'Template Globals'. Scroll down to the bottom of the page and you should find a blank box. Paste the code in the post above into the box - make sure that the first line is just

sub {

Then call it whatever you like. Then wherever you want the output just use the tag <%Nameofglobal%>
Quote Reply
Re: [afinlr] Adding Additional globals like <%meta_name%> In reply to
hiya, cheers for the help, worked like a charm :)

unfortuatly, i've now got another problem heh. Were using the <%category_short%> in the meta_description, problem is tho with that above, is that it doesnt echo out the category its in, just blanked out.

Any ideas/ways around this? this is the last part of it now i think.

Cheers.
Quote Reply
Re: [ryanbigmedia] Adding Additional globals like <%meta_name%> In reply to
Anyone got any idea's on this? cant see why it wont echo the category out. Or any workarounds? just need to echo the category its in, in normal text style, not linked.

Cheers.
Quote Reply
Re: [ryanbigmedia] Adding Additional globals like <%meta_name%> In reply to
It may be that category_short is not an available tag. You can use <%GT::Template::dump%> to see available tags.
Quote Reply
Re: [afinlr] Adding Additional globals like <%meta_name%> In reply to
hiya, yer i thougth that, but tested it outside of the <%meta_description%> tag, well the custom one which i've done like <%custom_meta_desc%> etc..

It just blanks, doesnt even give an error, its as if it isn't even looking.

Must be something to do with the custom code above.
Quote Reply
Re: [ryanbigmedia] Adding Additional globals like <%meta_name%> In reply to
Hi,

Sorry I don't understand what you mean by 'outside of the <%meta_description%> tag' - how are you using it inside the tag? Can you give the exact code you are trying?
Quote Reply
Re: [afinlr] Adding Additional globals like <%meta_name%> In reply to
hiya,

Yer, were using:

sub {
my $tags=shift;
if ($tags->{meta_name}){return;}
my $name=$tags->{Full_Name};
$name=~s,^([^/]+).*,$1,;
my $db = $DB->table('Category');
my $meta = $db->select('Meta_Description',{Full_Name=>$name})->fetchrow_array;
return $meta;
}

Our Structure is:
Category -> Anglia
London -> County -> Town.

'Category' were using to have variables of the category(town) the user is in, so on the front end you would see like: "Category in Town" (backend on the Meta Desc part in the Category Selector > Edit > Meta Desc would be: Category in <%category_short%>...

Then on the template it self it would just be <%custom_meta_desc%>

Problem is, is that with the custom tag above, it kills the <%category_short%> if its in the meta_description bit no the Categor Selector Part.

If <%category_short%> is just on the template part it works fine. but when you have multiple "changing category name in place, and category name for place" etc, makes it hard to find easier work arounds other than trying to fix the above code so it allows the <%category_short%> part to work.

Hope that makes sense :)

Cheers.
Quote Reply
Re: [ryanbigmedia] Adding Additional globals like <%meta_name%> In reply to
I'm still not sure I understand - are you trying to put the tag within the field in the Category database? If so, you can't do this.

Why not try something like this with the modified global below (called gettags):

<%if meta_name%><%gettags%>
<meta name="description" content="Category in <%Town%>: <%Meta%>">
<%endif%>

sub {
my $tags=shift;
if ($tags->{meta_name}){return;}
my $name=$tags->{Full_Name};
$name=~s,^([^/]+).*,$1,;
my $db = $DB->table('Category');
my $meta = $db->select('Meta_Description',{Full_Name=>$name})->fetchrow_array;
return {Meta=>$meta, Town=>$name};
}