Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 2016-09-26 23:53:42

richtestani
Plugin Author
Registered: 2009-11-08
Posts: 128

Understanding Plugin Preferences

I am building a new plugin, and require 1) get the current language setting, and 2) get the installed language packs.

I’ve tried a few ways but they produce an empty result, so either my brain is fried or there is a step I am missing.
Below is the general txt initialization.

if (@txpinterface == 'admin') {
          add_privs('rlt_shanoobi','1,2');
          add_privs('plugin_prefs.rlt_shanoobi','1,2');
          register_callback('rlt_shanoobi_setprefs', 'plugin_prefs.rlt_shanoobi');
          register_tab('extensions', 'rlt_shanoobi', 'Shanoobi');
          register_callback( 'rlt_shanoobi_css', 'admin_side', 'head_end');
          register_callback( 'rlt_shanoobi_script', 'admin_side', 'body_end');
          register_callback('rlt_shanoobi_init', 'rlt_shanoobi');
     }
    function rlt_shanoobi_init($e, $s)
    {
       //get_prefs()?
       $pref = get_prefs('language');
       //returns empty array
       //try a query
       $table = safe_pfx('txp_prefs');
       $row = safe_row('*', $table, 'name like "%lang%"');
       //return empty array
       $out = '';
      if($s == 'rlt_shanoobi_prefs') {
        $out =  rlt_shanoobi_prefs();
      } else {
        $out = rlt_shanoobi_main();
      }
        echo $out;
      }

I read the docs, but they were’t exactly clear.
In my tests above, there is no data in the returned queries. How do I get this value?

Thanks
Rich

Last edited by richtestani (2016-09-26 23:55:03)

Offline

#2 2016-09-27 08:13:10

etc
Developer
Registered: 2010-11-11
Posts: 5,053
Website GitHub

Re: Understanding Plugin Preferences

Try get_pref() (not get_prefs()). And text strings for the current language are normally stored in global $textarray.

Offline

#3 2016-09-27 17:55:46

makss
Plugin Author
From: Ukraine
Registered: 2008-10-21
Posts: 355
Website

Re: Understanding Plugin Preferences

BTW, function safe_row() already table prefixed.

$row = safe_row('*', 'txp_prefs', 'name like "%lang%" limit 1');

or

$rows = safe_rows('*', 'txp_prefs', 'name like "%lang%"');

aks_cron : Cron inside Textpattern | aks_article : extended article_custom tag
aks_cache : cache for TxP | aks_dragdrop : Drag&Drop categories (article, link, image, file)

Offline

Board footer

Powered by FluxBB