Please login or register.

Login with username, password and session length
Advanced search  

News:

You need/want an older version of sNews ? Download an older/unsupported version here.

Author Topic: auto generate meta tags  (Read 3315 times)

Vivvo

  • Newbie
  • *
  • Karma: 0
  • Posts: 20
auto generate meta tags
« on: December 21, 2007, 05:04:31 pm »

By default, when you creat a new article and enter the name of the article into the top box, it automaticly generatres that same name in the SEF (URL) friendly box below it like this example:

I enter this name in "Article Name" top box: Lets Go Fishing

This get "auto generated" in URL sEF box below it: lets-go-fishing

What I want to know is this, can this be expanded so in the META TAG and META KEYWORD boxes further down, they also get auto generated from the article title also like this below

META TAG: Keeps the exact same stucture as the article title: Lets Go Fishing

META KEYWORD gets generated like this: lets,go,fishing (with comas instead of minus sign)
Logged

Rui Mendes

  • Development,Testing, Support
  • Hero Member
  • *****
  • Karma: 195
  • Posts: 1009
  • sNews1.7
    • Comunidade Portuguesa
Re: How can I expand this feature
« Reply #1 on: December 22, 2007, 11:59:10 am »

Here is a Demo or Download file

Find red text and replace blue text in form_categories function
Quote
echo html_input('text', 'name', 't', $frm_name, l('name'), '', 'onchange="genSEF(this,document.forms[\'post\'].seftitle)"', 'onkeyup="genSEF(this,document.forms[\'post\'].seftitle)"', '', '', '', '', '', '', '');
      echo html_input('text', 'name', 't', $frm_name, l('name'), '', 'onchange="genSEF(this,document.forms[\'post\'].seftitle,meta,kw)"', 'onkeyup="genSEF(this,document.forms[\'post\'].seftitle,meta,kw)"', '', '', '', '', '', '', '');

A few lines down, before red line add blue text
Quote
   echo html_input('hidden', 'meta', 'meta', 'meta', '', '', '', '', '', '', '', '', '', '', '');
   echo html_input('hidden', 'kw', 'kw', 'kw', '', '', '', '', '', '', '', '', '', '', '');

   echo html_input('hidden', 'task', 'task', 'admin_category', '', '', '', '', '', '', '', '', '', '', '');

Find your genSEF function and replace with this
Code: [Select]
// generate SEF urls
function genSEF(from,to,meta,kw) {
if (allowsef == true) {
var str = from.value.toLowerCase();
meta.value = str;
str = str.replace(/[^a-z 0-9]+/g,'');
kw.value = str.replace(/\s+/g, ",");
str = str.replace(/\s+/g, "-");
to.value = str;
}
}


Find this in form_articles function
Quote
   echo html_input('form', '', 'post', '', '', '', '', '', '', '', '', '', 'post', $frm_action, '');
   echo html_input('fieldset', '', '', '', '', '', '', '', '', '', '', '', '', '', $frm_fieldset);
   echo html_input('text', 'title', 'at', $frm_title, l('title'), '', 'onchange="genSEF(this,document.forms[\'post\'].seftitle)"', 'onkeyup="genSEF(this,document.forms[\'post\'].seftitle)"', '', '', '', '', '', '', '');

and replace red text to
Quote
   echo html_input('text', 'title', 'at', $frm_title, l('title'), '', 'onchange="genSEF(this,document.forms[\'post\'].seftitle,document.forms[\'post\'].description_meta,document.forms[\'post\'].keywords_meta)"', 'onkeyup="genSEF(this,document.forms[\'post\'].seftitle,document.forms[\'post\'].description_meta,document.forms[\'post\'].keywords_meta)"', '', '', '', '', '', '', '');
« Last Edit: December 23, 2007, 01:28:57 pm by Rui Mendes »
Logged
Need a Job on Europe. Linkdin - Facebook / Group

Fred K

  • Still trying to learn stuff
  • ULTIMATE member
  • ******
  • Karma: 130
  • Posts: 2728
    • Personal
Re: How can I expand this feature
« Reply #2 on: December 22, 2007, 03:27:26 pm »

That's quite clever! Thumbs up (haven't tested it, but I will...)
Logged

Rui Mendes

  • Development,Testing, Support
  • Hero Member
  • *****
  • Karma: 195
  • Posts: 1009
  • sNews1.7
    • Comunidade Portuguesa
Re: How can I expand this feature
« Reply #3 on: December 22, 2007, 06:35:50 pm »

I've a fix for categories, now Works perfect
« Last Edit: December 22, 2007, 07:39:02 pm by Rui Mendes »
Logged
Need a Job on Europe. Linkdin - Facebook / Group

Vivvo

  • Newbie
  • *
  • Karma: 0
  • Posts: 20
Re: How can I expand this feature
« Reply #4 on: December 22, 2007, 07:26:44 pm »

There seems to be  problem though, after installing the changes. If you go into your category section and view a "category" you have already created - the "Name" section is now blank and doesnt display the name you previously had in that box for your category, and if you re-enter the name and save it. It still remains blank and shows you a warning that you cannot have a cateogory with no name.

I can see you have attached a snews.php file above, if that contained the fix for this problem. I cannot use that file, as I have made to many changes to my site to just over-write my snews.php file with that one. As I have things like the Digg mod installed and Adsense in threads. Plus a lot of BUG Fixes installed
« Last Edit: December 22, 2007, 07:37:07 pm by Vivvo »
Logged

Rui Mendes

  • Development,Testing, Support
  • Hero Member
  • *****
  • Karma: 195
  • Posts: 1009
  • sNews1.7
    • Comunidade Portuguesa
Re: How can I expand this feature
« Reply #5 on: December 22, 2007, 07:37:03 pm »

Really I tried and works perfect. Try Demo
« Last Edit: December 23, 2007, 12:02:00 am by Rui Mendes »
Logged
Need a Job on Europe. Linkdin - Facebook / Group

Rui Mendes

  • Development,Testing, Support
  • Hero Member
  • *****
  • Karma: 195
  • Posts: 1009
  • sNews1.7
    • Comunidade Portuguesa
Re: How can I expand this feature
« Reply #6 on: December 23, 2007, 12:04:22 am »

Bug fixed. Download attach file in my first post.

Please try and tell me.
« Last Edit: December 23, 2007, 01:24:31 pm by Rui Mendes »
Logged
Need a Job on Europe. Linkdin - Facebook / Group

Vivvo

  • Newbie
  • *
  • Karma: 0
  • Posts: 20
Re: How can I expand this feature
« Reply #7 on: December 23, 2007, 03:00:11 am »

I cannot download the attached file, you asking me to overwrite the snews.php file which I cannot do
Logged

Keyrocks

  • Doug
  • ULTIMATE member
  • ******
  • Karma: 449
  • Posts: 6020
  • Semantically Challenged
    • snews.ca
Re: How can I expand this feature
« Reply #8 on: December 23, 2007, 03:57:13 am »

I cannot download the attached file, you asking me to overwrite the snews.php file which I cannot do
You do not have to over-write your existing snews.php file. Instead, re-name it to - snews_XX.php in order to disable it and keep it intact. Then copy your database settings from snews_XX.php to Rui's snews.php file... and put Rui's file in your domain root (where the other one is) and you will be running on the new file. Then, when you are done and you want to go back to your file... re-name Rui's file to snews_rui.pbp and change the name of your file back to snews.php... and you're back the way you were before you started.  ;)
Logged
Do it now... later may not come.
-------------------------------------------------------------------------------------------------
sNews 1.6 MESU | sNews 1.6 MEMU

Rui Mendes

  • Development,Testing, Support
  • Hero Member
  • *****
  • Karma: 195
  • Posts: 1009
  • sNews1.7
    • Comunidade Portuguesa
Re: How can I expand this feature
« Reply #9 on: December 23, 2007, 04:03:31 am »

Thanks Dougie. Do like Key says, and will work for sure.
Logged
Need a Job on Europe. Linkdin - Facebook / Group