0

new user to ExpressionEngine here. I recently developed a plugin that I'm using to apply a filter to content, but I run into an issue when the plugin isn't installed. Is there a way to check if a plugin in installed and, if it is, apply the filter?

Right now, the syntax is similar to the following:

{exp:myFilter}
  {content}
{/exp:myFilter}

What I was looking for is something like this

{if pluginIsInstalled}
  {exp:myFilter}
    {content}
  {/exp:myFilter}
{elseif}
  {content}
{/if}

Thanks in advance!

0

There is no EE tag (that I am aware of at least) that will report installed plugins directly. However, if you know the short_name of the plugin but you can get what you need using the exp:query tag thusly:

{exp:query 
    sql="SELECT plugin_package 
         FROM exp_plugins 
         WHERE plugin_package = 'plugin_short_name_here';"
}
    {plugin_package}
{/exp:query}

This would return the short_name of the plugin if the plugin is installed, and nothing if not. You can use this behaviour to drive your conditional.

So if the short_name of your plugin is cats_for_coding then your code would possibly look like this:

{exp:query 
    sql="SELECT plugin_package 
         FROM exp_plugins 
         WHERE plugin_package = 'cats_for_coding';"
}
    {if no_results}
        {content}
    {/if}
    {exp:cats_for_coding}
        {content}
    {/exp:cats_for_coding}
{/exp:query}

This works for plugins - if you want to do the same for modules use exp_modules and module_name in the SQL.

HTH

0

if you use the template manager it'll provide feedback (on hover i believe) if a plugin isn't installed. this kind of logic typically doesn't have a place in the templates: the one coding templates should know wether a plugin is installed i guess

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.