lonalore / metatag

e107 (v2) plugin - This plugin allows you to automatically provide structured metadata, aka "meta tags", about a website.
GNU General Public License v3.0
12 stars 10 forks source link

Question - just discussion #12

Closed Jimmi08 closed 5 years ago

Jimmi08 commented 5 years ago

Hi, I am trying to find the solution on how to use your plugin without any code changes or without creating a new plugin for this.

What I am trying to do: for $config['download-category'] add new token if plugin is installed

'download:category:canonical' => array(
                    'help'    => 'Canonical url',
                    'handler' => 'metatag_entity_download_category_token_canurl',
                    'file'    => '{e_PLUGIN}jmdownload/includes/metatag.canonical.php',
),

and change default

'default' => array(
'og:canonical'             => '{download:category:canonical}',
)

I have working solution with jmdownload plugin where I have my own browser of download categories with new event "jmdownload-category"

I could:

  1. to require with jmcanonical plugin to install jmdownload, but I dislike this. That plugin is the only solution for missing core functionality and it's planned to remove it during the time. It's a personal solution, it's not shared.

  2. I tried to add e_metatag and e_event and tokens to jmcanonical plugin, but it was ignored. Or I did it the wrong way.
    Is possible override/change settings for e_metatag with another plugin? I think it depends on the order of loading addons. the metatag is after jmcanonical and so it's config is used.

Any ideas? Thanks

lonalore commented 5 years ago

Hi! So you want to alter/override default metatag definition (like $config['download-category']) using e_metatag.php in your own plugin?

Jimmi08 commented 5 years ago

Hi, something like that. Or just add or change some keys. No idea. There is nothing like a priority with e107 addons, so you can't change the order of them. But those are just arrays, there has to be some way...

But did you get my point? I want to have one perfect metatag plugin, but I want to have the possibility to override some of its settings. Adding new ones works flawlessly.

lonalore commented 5 years ago

Currently, there is no way to alter $config array, but I work on it. There will be an altering method here.

lonalore commented 5 years ago

It is now possible to alter $config array using config_alter() method in your e_metatag.php file.

/**
 * Class jmdownload_metatag.
 *
 * Usage: PLUGIN_metatag
 */
class jmdownload_metatag
{

    /**
     * Alter config before caching takes place.
     *
     * @param $config
     */
    public function config_alter(&$config)
    {
        $config['download-category']['token']['download:category:canonical'] = array(
            'help'    => 'Canonical url',
            'handler' => 'metatag_entity_download_category_token_canonical_url',
            'file'    => '{e_PLUGIN}jmdownload/includes/metatag.canonical.php',
        );
    }

}
Jimmi08 commented 5 years ago

Report: Tested with news.

    public function config_alter(&$config)
    {
    $config['news']['token']['news:canonical'] = array(
            'help'    => 'Canonical url',
            'handler' => 'metatag_entity_news_token_canurl',
            'file'    => '{e_PLUGIN}jmcanonical/includes/metatag.canonical.php',
        );    
    $config['news']['default']['canonical'] = '{news:canonical}';     
    } 

Ì can see it works image

But no changes in editing. Then I found that I am not able to delete cached data anymore.

So I reinstalled plugin (with deleting tables). And plugin stopped to work. I will create new issue, it's not related to this. I know what is wrong. Sec.