e107sk.com

Recent Content List e107 Core

BOOK_CHAPTERS shortcode on 14 Jul 2020

Render All visible Chapters from a specific Book.

Uses "listChapter" template key. ie. $CHAPTER_TEMPLATE[---TEMPLATE --]['listChapters']

{BOOK_CHAPTERS: name=book-sef-url}
{BOOK_CHAPTERS: name=book-sef-url&template=xxxxx&limit=3}

$parm['name']
$parm['template'] - $tmplKey = varset($parm['template'],'panel');
$parm['class']
 

CHAPTER_MENUS shortcode on 14 Jul 2020

Render All visible Menus from a specific chapter. Very often used for portfolio on homepage.

{CHAPTER_MENUS: name=chapter-sef-url}
{CHAPTER_MENUS: name=chapter-sef-url&template=xxxxx}

$parm['name']
$parm['template'] - overrides value ['menu_template']
$parm['class']
$parm['active']
$parm['limit']

Example for 2 cycles:

{CHAPTER_MENUS: name=portfolio&template=portfolio}
{CHAPTER_MENUS: name=portfolio&template=portfolio-modal}

CMENU shortcode on 14 Jul 2020

 {CMENU=feature-1}

Renders a menu called 'feature-1' as found in the e107_page table

 Templating:  template key "nav" +  'showPage' in chapter_template.php

 Using:

- in Menu Manager: the only caption can be set, it always displayed all chapters + pages  (template nav is used), but shortcode is used for rendering (good)

- as a shortcode: - 

{PAGE_NAVIGATION: template=navdoc&auto=1}
{PAGE_NAVIGATION: chapter=4}
{PAGE_NAVIGATION: book=3&pages=true}

 

this shortcode uses e_sitelinks addon 

Chapter Menu on 14 Jul 2020

 Templating:  template key "panel" in chapter_template.php

 Using:

- in Menu Manager: the only caption can be set, it always displayed all chapters with template panel

- as a shortcode: - parameter book is available, so you can display only chapters/pages from one book, but again, chapters have to have template "panel" 

It has no logic...  not mention you need to know book ID . And there is hardcoded 24 items limit.

Example:

{MENU: path=page/chapter&book=7}

You can display only chapter shortcodes. No page/menus list. 

Next notice: as soon as you use panel template for book, this menu will fail.

 The menu is not working, see the issue

Custom plugin preferences on 13 Jun 2020

Retrieve all plugin's preferences:

$plugPrefs = e107::getPlugConfig('your_plugin')->getPref();


for using in class:

private $plugPrefs = array();
$this->plugPrefs = $plugPrefs; 

Another way:

$plugPrefs= e107::pref('your_plugin');

Retrieve single plugin preference:

$perPage = e107::pref('your_plugin', 'your_preference');

Update one preference:

To save new value:

e107::getPlugConfig('your_plugin')->set('your_preference', $addonsList)->save(true);


save(true) - value will be replaced
save(false) - value will be added

empty array:

e107::getPlugConfig('visualbuilder')->set('visualbuilder', array())->save(true);

Core caching on 14 May 2020

 Just some

online_menu_totals
wmessage
news
'newsarchive' _caption,_title,_diz,_rows
"nq_othernews"
news_php_extend_'.$id.'_'
'nq_news_latest_menu_'.md5(serialize($parm).USERCLASS_LIST.e_LANGUAGE);
'nq_news_categories_menu_'.md5(serialize($parm).USERCLASS_LIST.e_LANGUAGE);
'nq_news_months_menu_'.md5(serialize($parm).USERCLASS_LIST.e_LANGUAGE);
'news.php_default_'
'news.php_'.e_QUERY
comment.php?{$table}.{$id}
nq_chatbox
nomd5_linkwords
nomd5_user_ranks
'menus_'.USERCLASS_LIST.'_'.md5(e_LANGUAGE.$menu_layout_field)

Retrieve Cache on 14 May 2020

Example (from shortcode):

$e107cache = e107::getCache();

if($cacheData = $e107cache->retrieve('your_code'))
{
return $cacheData;
}

$cache_data = '';

$cache_data = $text;

$e107cache->set('your_code', $cache_data);
return $cache_data;


define('LW_CACHE_ENABLE', FALSE);

define('LW_CACHE_TAG', 'nomd5_linkwords');

if(LW_CACHE_ENABLE && ($temp = e107::getCache()->retrieve_sys(LW_CACHE_TAG))) {}

if(!vartrue($temp)) // Either cache disabled, or no info in cache (or error reading/processing cache)
{

}

Delete cache in Admin UI on 14 May 2020

Example:

public function afterUpdate($new_data, $old_data, $id)
{
e107::getCache()->clear("your_code");
}

Example:

define('LW_CACHE_TAG', 'nomd5_linkwords');
e107::getCache()->clear_sys(LW_CACHE_TAG);

public function afterCreate($new_data, $old_data, $id)
{
e107::getCache()->clear_sys(LW_CACHE_TAG);
// do something
}

public function afterUpdate($new_data, $old_data, $id)
{
e107::getCache()->clear_sys(LW_CACHE_TAG);
// do something
}


public function afterDelete($deleted_data, $id, $deleted_check)
{
e107::getCache()->clear_sys(LW_CACHE_TAG);

}

Hidden field on 04 May 2020

 $frm = e107::getForm();
 $text = $frm->hidden('name','value');

$ret = e107::getForm()->hidden('questionId',$field['questionId']);

Loading lan files on 27 Apr 2020

How to load non-standard file names

 e107::lan('pcontent', "lan_content"); 

It is impossible (and useless) to rewrite old lang files, mainly if they are used for both areas (admin and front too). It would mean to rewrite each mention in other code too. I am not able to remember what way to use when, so I started to use this way (second parameter is file name inside languages/LANGUAGE/ folders)

Official documentation on 27 Apr 2020

User Data on 26 Apr 2020

How to get user Data

Example from old plugin

$sql5 = new db;
  $sql5->mySQLresult = @mysql_query("select * from ".MPREFIX."user where user_id='".intval($row4['news_com_author'])."';");
  $row5 = $sql5->db_fetch();
  $newscomauthor = $row5['user_name'];

Now:

$row5 = e107::user(intval($row4['news_com_author']));
  $newscomauthor = $row5['user_name'];
Official documentation:
e107::user($user_id);
$userData = e107::user(); // Example - currently logged in user. 
$userData = e107::user(5); // Example  User ID #5.

How to replace form fields on 21 Apr 2020

how to replace old form fields with new ones

TEXT FIELD

CHANGED order of parameters
Before:
function form_text($form_name, $form_size, $form_value, $form_maxlength = FALSE, $form_class = "tbox form-control", $form_readonly = "", $form_tooltip = "", $form_js = "") {
...
	return "\n<input class='".$form_class."' type="text">";
}
Now:
function text($name, $value = '', $maxlength = 80, $options= array()) 
{
...
	return "<input type='".$type."' name="{$name}" value="{$value}">get_attributes($options, $name)." />";
}
replacing:
$f->form_text($pname."_title", "40", $tp->toHTML($fi["title"]), "200", "form-control")
$frm->text($pname."_title", $tp->toHTML($fi["title"]),  "200", 'size=40&class=form-control')
So: 1. rename method name 2. delete 2nd parameter (4th becomes 3rd) 3. set former size parameter like size=99 as 4th parameter Options: - if parameter class is not defined, class tbox is used - if bootstrap 3 (not 4) is used, class form-control is used NOTE for me: ALWAYS set class, not let it for core - selectize script is used if you use options 'id' and 'selectize' (then class is emptied) - option 'type' is available (the only email, otherwise has value text) - option 'typehead' with value 'users' is marked as removed soon Example with placeholder:
$frm->text($pname."_googlemap",  $tp->toHTML($fi["googlemap"]), "200", "size=40&class=form-control&placeholder=".CUP_INFO_ADDRESS)

Textarea

Before;
function form_textarea($form_name, $form_columns, $form_rows, $form_value, $form_js = "", $form_style = "", $form_wrap = "", $form_readonly = "", $form_tooltip = "") {
...
		return "\n<textarea class="tbox form-control">".$form_value."</textarea>";
Now:
function textarea($name, $value, $rows = 10, $cols = 80, $options = array(), $counter = false) {
...
		return "<textarea>get_attributes($options, $name).">{$value}</textarea>".(false !== $counter ? $this->hidden('__'.$name.'autoheight_opt', $counter) : '');
CHANGED order of parameters
So: - swap 4th and 2nd parameters - everything else move to options - set 6th parameter as true Example:
$frm->form_textarea($pname."_info", "10", "20", $tp->toHTML($fi["info"]), "200", "form-control")
$frm->text($pname."_googlemap",  $tp->toHTML($fi["googlemap"]), "200", "size=40&class=form-control&placeholder=".CUP_INFO_ADDRESS)

Open form

CHANGED order of parameters
$frm->form-open("post", e_SELF, $pname."_form", "", " class='form-horizontal'")
- rename method - move form name as first parameter - replace 3rd with NULL (in this case e_REQUEST_URI is used)[/prism]
$frm->open($pname."_form",'post', null, array('class'=>'form-horizontal'))
Another example:
form_open($form_method, $form_action, $form_name = "", $form_target = "", $form_enctype = "", $form_js = "")

Checkbox

function form_checkbox($form_name, $form_value, $form_checked = 0, $form_tooltip = "", $form_js = "") {
function checkbox($name, $value, $checked = false, $options = array())

Select

just renaming method select_open option select_close
function form_option($form_option, $form_selected = "", $form_value = "", $form_js = "") {
...
return "\n";
}
function option($option_title, $value, $selected = false, $options = '')
return "";

Social Constants on 19 Nov 2019

 

XURL_FACEBOOK    
XURL_TWITTER    
XURL_YOUTUBE
XURL_GOOGLE in custom used for VKontakte
XURL_LINKEDIN
XURL_GITHUB
XURL_FLICKR
XURL_INSTAGRAM
XURL_PINTEREST
XURL_STEAM
XURL_VIMEO

Used files on 19 Nov 2019

 

e_SIGNUP e107_class.php signup.php or customsignup.php
e_LOGIN e107_class.php login.php or customlogin.php

e107 Path constants on 19 Nov 2019

Path related constants

e_HTTP e107_class.php $_SERVER['PHP_SELF'] + modifications
SITEURLBASE e107_class.php modifications + $_SERVER['HTTP_HOST'] 
SITEURL e107_class.php SITEURLBASE.e_HTTP
e_BASE e107_class.php
e_BASE_SELF NOT USED ANYMORE
e_SELF $_SERVER['HTTP_HOST'] + $_SERVER['PHP_SELF'] [ $_SERVER['SCRIPT_FILENAME'] ]
THEME
THEME_ABS available in replaceConstants()
e_ROOT class2.php realpath(dirname(__FILE__)."/");

Core Preferences on 20 Aug 2019

How to get the value of one needed preference?


Example for the list of installed plugins:

$builder_pluglist = e107::getPref('plug_installed');

Where to find used core pref name?


In admin area: Tools / Database / Preferences Editor

How to manage core prefs from custom plugins

This is the way I have confirmed as working... 

$pref = e107::getPref();
$core_pref = e107::getConfig();

the form works with $pref

$core_pref->setPref($pref)->save(false, true);

if pref is multilanguage, it's a bit complicated according to admin/meta.php file 

How to change only one core pref

e107::getConfig('core')->setPref('prefnamet', $new_value);
/**
* Save object data to DB
*
* @param boolean $from_post merge post data
* @param boolean $force
* @param mixed $session_messages null: normal messages displayed, true: session messages used, false: no messages displayed. 
* @return boolean|integer 0 - no change, true - saved, false - error
*/
e107::getConfig('core')->save(true,false,false);

Not clear what $from_post means. With one pref true, with full $pref false?

News constants on 17 Aug 2019

Constants used in news plugin, mostly from legacy reason
NEWS_NEXTPREV_NAVCOUNT number of navigation items to be shown, minimal allowed value is 4, default is 10 define('NEWS_NEXTPREV_NAVCOUNT', 6);  in theme.php
      >>  

Other links

Follow us