Make a Lasting Impression

Join the Mailing List

Who's Online

25 user(s) are online (7 user(s) are browsing Support Forums)

Members: 0
Guests: 25

more...
ImpressCMS proudly uses SourceForge
ImpressCMS on Ohloh.net





Meta_keys in modules/core
Home away from home
Joined:
2007/12/4 9:00
From Derbyshire/UK
Posts: 2076
Where are the meta key values generated?

for example.

if i use the content module & don't enter any meta keywords, they are automatically created.

I can't see where in the module they are created.

I need to know this because, i've added some html comments to the filtering. & when the HTML is filtered on input, it adds those comments to the HTML


<!-- input filtered -->
<!-- 
cleaned using htmlpurifier -->


but i have noticed the meta key generation is adding those comments to the keys.

I need to edit the meta key generator to ignore < !-- -- > comments in the content body

Posted on: 2012/8/4 13:13
_________________
Live as if you were to die tomorrow, Learn as if you were to live forever

The beauty of a living thing is not the atoms that go into it, but the way those atoms are put together!
Transfer the post to other applications Transfer


Re: Meta_keys in modules/core
Home away from home
Joined:
2007/12/4 9:00
Posts: 1116
I'm not sure if this is what you are looking for, but I usually use:


$icms_metagen 
= new icms_ipf_Metagen($startObj->getVar("title"), 
            
$startObj->getVar("meta_keywords""n"), $startObj->getVar("meta_description""n"));
    
$icms_metagen->createMetaTags();


Or in the class file of an SEO enabled object, there is:


class mod_cms_Start extends icms_ipf_seo_Object

Posted on: 2012/8/4 13:33
Transfer the post to other applications Transfer


Re: Meta_keys in modules/core
Home away from home
Joined:
2007/12/4 9:00
From Derbyshire/UK
Posts: 2076
ok i found ipf_metagen

but nothing i do in there seems to alter anything.

even adding exit(); to the functions in there doesn't do anything.

Posted on: 2012/8/4 14:35
_________________
Live as if you were to die tomorrow, Learn as if you were to live forever

The beauty of a living thing is not the atoms that go into it, but the way those atoms are put together!
Transfer the post to other applications Transfer


Re: Meta_keys in modules/core
Home away from home
Joined:
2010/2/12 23:04
From Germany
Posts: 678
The meta informations will be generated on submit if $seoEnabled = TRUE in icms_ipf_object, which will be done in module object constructor by $this->initiateSEO() The function

$icms_metatags 
= new icms_ipf_metagen($obj->title(), $obj->metakeywords(), $obj->meta_description();
$icms_metagen->createMetaTags();

is used in frontend. If you have seoEnabled = TRUE; the object handler calls the necessary icms_ipf_metagen functions in the insert() function to generate meta keywords and meta description

Posted on: 2012/8/4 15:24
Transfer the post to other applications Transfer


Re: Meta_keys in modules/core
Home away from home
Joined:
2007/12/4 9:00
From Derbyshire/UK
Posts: 2076
that's what i thought.

but nothing i do seems to change it.

to replicate the issue.

install icms 1.3.3 from the 1.3 branch.

install content module (trunk version)

make sure tinymce editor is used.

create new content (i simply used an image from imagemanager)

now submit the content.

go back & edit the content, you will see the following in meta keywords field


<!-- cleaned with htmlpurifier --><!-- input filtered -->


because i added those comments to the filtering so we can see where filtering was being done (input or output)

they are also present in the content meta_key field.

what I am trying to do is to make the meta key generator ignore any html comments.

i tried in icms_ipf_metagen function findMetaKeywords()


public function findMetaKeywords($text$minChar) {
        
$keywords = array();

        
$text $this->purifyText($text);
        
$text $this->html2text($text);

        
$text preg_replace("/([^rn])rn([^rn])/""\1 \2"$text);
        
$text preg_replace("/[rn]*rn[rn]*/""rnrn"$text);
        
$text preg_replace("/[ ]* [ ]*/"' '$text);
        if (
$c preg_match_all ("/(<!--.*?-->)/is"$text$matches)) {
            foreach (
$matches as $match) {
                
$text str_replace($match''$text);
            }
        }
        
$text icms_core_DataFilter::stripSlashesGPC($text);

        
$originalKeywords preg_split ('/[^a-zA-Z'"-]+/', $text, -1, PREG_SPLIT_NO_EMPTY);

        foreach ( $originalKeywords as $originalKeyword) {
            $secondRoundKeywords = explode("", $originalKeyword);
            foreach ( $secondRoundKeywords as $secondRoundKeyword) {
                if (strlen($secondRoundKeyword) >= $minChar) {
                    if (!in_array($secondRoundKeyword, $keywords)) {
                        $keywords[] = trim($secondRoundKeyword);
                    }
                }
            }
        }
        return $keywords;
    }


i added a preg_match_all()

but still doesn't remove the comments.

Posted on: 2012/8/4 16:27
_________________
Live as if you were to die tomorrow, Learn as if you were to live forever

The beauty of a living thing is not the atoms that go into it, but the way those atoms are put together!
Transfer the post to other applications Transfer


Re: Meta_keys in modules/core
Home away from home
Joined:
2010/2/12 23:04
From Germany
Posts: 678
Why you don't just strip html comments first?

Posted on: 2012/8/4 17:04
Transfer the post to other applications Transfer


Re: Meta_keys in modules/core
Home away from home
Joined:
2007/12/4 9:00
From Derbyshire/UK
Posts: 2076
that's what i'm trying to do

Posted on: 2012/8/4 17:17
_________________
Live as if you were to die tomorrow, Learn as if you were to live forever

The beauty of a living thing is not the atoms that go into it, but the way those atoms are put together!
Transfer the post to other applications Transfer


Re: Meta_keys in modules/core
Home away from home
Joined:
2010/2/12 23:04
From Germany
Posts: 678
What about something like this:

$text 
preg_replace('/<!--.*-->/sU'''$text);

Posted on: 2012/8/4 17:34
Transfer the post to other applications Transfer


Re: Meta_keys in modules/core
Home away from home
Joined:
2007/12/4 9:00
From Derbyshire/UK
Posts: 2076
doesn't work :S

i actually think the meta_key field is being treated as HTML when it's submitted to the DB instead of text.

Posted on: 2012/8/4 17:53
_________________
Live as if you were to die tomorrow, Learn as if you were to live forever

The beauty of a living thing is not the atoms that go into it, but the way those atoms are put together!
Transfer the post to other applications Transfer


Re: Meta_keys in modules/core
Home away from home
Joined:
2010/2/12 23:04
From Germany
Posts: 678
maybe try something like

preg_replace
('/<!--[^[](.*?)-->/Uis'''$text);

Posted on: 2012/8/4 18:08
Transfer the post to other applications Transfer






You can view topic.
You cannot start a new topic.
You cannot reply to posts.
You cannot edit your posts.
You cannot delete your posts.
You cannot add new polls.
You cannot vote in polls.
You cannot attach files to posts.
You cannot post without approval.

[Advanced Search]