You are here:Home»KB»Web Design»CMS»Joomla»Extensions»Mosets Tree»My Mosets Tree Notes
Thursday, 17 December 2015 13:40

My Mosets Tree Notes

Written by

General Mosets Notes

General

  • records are currently refered to as links, this is confusing and should renamed to records (or the like)
  • i dont think moset tree has an intro text box (can be added) but will rather rely on 'read more'

the way mosets tree gets around multiple directories is as follows

  • each entry has all fileds created for it in the mysql database (only applies to core fields)
  • only those fileds that are visible in that section are then populateed when an entery is created/updated
  • the availability of the stored vaules will be determined by the category/section the entry is moved to
  • by all field existing you can easily move an entery anywhere in mosets tree
  • there must be coding that still allows fileds with nothing to be shown safely
  • when you creae a custom filed all enteries will recieve it whther they can access it or not

Template

Notes

  • root categories can overide all global settings
  • when applying a new template make sure you set apply this to all sub catgegories to make things run as you expect (ie all child cats using the same template)

Link Building

this seems to be an internal plugin that builds <a> tags

$this->plugin( 'ahreflisting', $link, $link_name->getOutput(2), '', array("edit"=>false,"delete"=>false), 1 );

Accessing field data in the template

// these do similiar things i think
$website = $link_fields->getFieldById(12);	// for core and custom, only returns if the feld is active. this loads the 12th field
$website = $link->link_website;			// for core only, always returns the vaule no boolean or permissions. link_website is a core table field/column from #__mt_links

ie. the code below checks to see if the website field is available and then if it is does it have a vaule, if both are positive then run code

// Website
$website = $link_fields->getFieldById(12);
if(!is_null($website) && $website->hasValue()) { echo '<p class="website">' . $website->getOutput(2) . '</p>'; }

Use Main Index template page' options is set by default to on

When creating a new category in back end,  the 'Use Main Index template page' options is set by default to on, this should be set to off by default.

Fix

  • edit the file
    administrator/components/com_mtree/models/forms/category.xml
  • search for COM_MTREE_USE_MAIN_INDEX_TEMPLATE_PAGE which is (COM_MTREE_USE_MAIN_INDEX_TEMPLATE_PAGE="Use Main Index template page" from administrator/language/en-GB/en-GB.com_mtree.ini)
  • change default="1" option to default="0"
  • upload the new XML file and ovewrite administrator/components/com_mtree/models/forms/category.xml
  • update the database with SQL if you need to - I am not sure this is required for anything

Fields

fields && classes

  • where does the filedtypes configuration get saved = - paremeters, - standard has own table
  • can i just update the core weblinks = yes
  • how does a coreplugin know how to use the core link database = it is decides by the class name and possible the file names aswell of the field type
  • moset fields are installable (nb anything can be made installable with an xml, it is just moserts made them all nice)
  • when writing a new field is there a particluar order the functions should go in
  • a lot of code duplication, there is no need for field code to be in the mField class, it should all be exported to the fields themselves.
  • this basically has all the shared functions in classes for the fields - D:\Documents\websites\lancast\htdocs\administrator\components\com_mtree\mfields.class.php
  • a validator Var is usually created by a field, i.e. var $dataValidator = 'validate-url';  is echo'ed for a javascript to set the type of filed validation, this is set in the <input> tag. the validation is set in that particular fileds class in a function
  • how does a field decide wheather to create a new custom field entry in the database or use the core fileds already there - class name and filename
  • change a field type between a custom and a core field - you can change a field to and from a core filed by changing its name, changing the mysql database column 'iscore' bit in the field's row, and make/delete a new column in #__mt_links table

mweblink

  • mweblink does not show spider or go button because the setting is missing in the config
  • mweblink has incorrectely used getValue() for a userlookup. i think i will change this to getAccess
  • mweblink custom field should be merged with website
  • mweblink is missing spider link parameter? and this is why it is not showing
  • mweblink - is missing hideprotocoloutput setting in the xml file, this also has not been properely been implemented in mweb
  • to use the core table weblink filed basically i just need to update the code of that field. it will automatically change the strage location of the data. so no major re-do. i could in theory just rename mweblinks and overite the already present files and that would do the trick.
  • copying all the functions down from 'root' will make altering the plugin much easier. no 100% nessaray but easier.
  • i should copy all of the functions required into my new field and make a note of the ones i replicate.

field class example - mweblink

  • class mFieldType_mweblink extends mFieldType_weblink = the fields class and is found in mweblink.php
  • mFieldType_weblink - is found in htdocs\administrator\components\com_mtree\mfields.class.php, and is what i would class as the root class. this class is also extended by coreweblink
  • a general class note: basically if the function is in the clas that is doing the extending, that function is used. if the function is not present, the function in the class that has been extended (call it the parent!!) is used. This is a general class thing but should be remembered.

mtree.php

D:\Documents\websites\lancast\htdocs\administrator\components\com_mtree\mtree.php

  • this is an important file, it controls how fields are handled
  • search for mFieldType - line 1066 (custom) and 1106 (core)
  • line 1184 loads all values for that record, both core and custom.
  • line 691 (# Load all CORE, published and assigned custom fields)
    1. it basically checks to see if there is a table in the core field table that matches the class name (mFieldType_weblink - mFieldType_ = weblink)
    2. the namimg of the class and files names is important to its feature. you could easily add a new core field by creating a new table in the core files bit and then a new plugin

creating a CF value (custom field)

line 5320 - D:\Documents\websites\lancast\htdocs\administrator\components\com_mtree\mtree.php

table structure
id
cf_id
link_id
value
attachment - Default = 0
counter  - Default = 0

therefore only the first 4 things are created with values

Custom Fields

  • only core fields are stored(have their own column) in #__mt_links
  • custom fields link to links by this by link_id and cf_id (for the custom filed)
  • custom link values are stored in #__mt_cfvalues
  • custom fields 'custom' config settings are stored in #__mt_customfields 'params' field.
  • All the mandatory settings for a field have their own column in this table (#__mt_customfields).
  • This table (#__mt_customfields) does both core and custom fields. It is also where you can set the 'iscore' bit
  • you cannot install (via joomla installer) a new field as a core plugin as there seems to be no switch or method to create a new column in the #__mt_links table
  • you can update a core plugin either via joomla update (potentialy because you install fields via joomla extension manager and tehre is a <update> field in the fields xml)
  • when you have overitten a core field with your new code, you must open the fields config and save changes so the parameters that are stored then match up
  • it is only wise to alter a core field if the stored data is going to be the same, just how you handle it is different.
  • core field values might only be created when an entry is made rather than when the entry is saved

 

Read 1051 times Last modified on Thursday, 17 December 2015 16:07