SLP_Power_Directory_UI_Shortcode_slp_directory
extends SLPlus_BaseClass_Object
in package
The slp_directory shortcode processor.
[slp_directory]
[slp_directory by="city" style="list"]
[slp_directory by="city" style="list_with_count" locator_page="/locations/"] [slp_directory by="city" style="list_with_count" landing_page="/locations/"]
[slp_directory by="city" locator_page="/locations" locator_data="sl_id"]
[slp_directory by="city" filter_by="
[slp_directory style="landing_page"]
[slp_directory style="title"]
Attributes: o by = a store property to group data by o filter_by = an SQL clause to include/exclude locations i.e. filter_by="sl_country='USA'" o if_blank_use = alternate data field if the group by field is blank o locator_page = a URL for the locator page on the site o style = list, list_with_count, landing_page, title
By attribute: Takes a location property in the form of the field name. sl_store, sl_city, etc. * The following field names are aliased for ease-of-use: o store, sl_store, name = the store name field (sl_store) o city, sl_city = the city field (sl_city)
Style attribute: Determines the output format of the sl_directory shortcode. o list = a list of the "by attribute" values from the current location database, for example a list of cities, for example "Charleston" o list_with_count = same as list but with the count of locations with that property, for example "Charleston (2)"
Table of Contents
Properties
- $addon : SLPPower
- $addon : mixed
- $alternate_groupby_field : string
- $attribute_defaults : array<string|int, string>
- $attributes : array<string|int, string>
- $attributes : mixed
- $content : string
- $content : mixed
- $filter_by : string
- $group_by : string
- $landing_page : SLP_Power_Directory_Landing_Page
- $name : string
- $name : mixed
- $slplus : SLPlus
- $uses_slplus : bool
- $slplus : mixed
- $uses_slplus : mixed
- $alternate_groupby_field : mixed
- $attribute_defaults : mixed
- $filter_by : mixed
- $group_by : mixed
- $landing_page : mixed
- $only_with_category : mixed
Methods
- __construct() : mixed
- __get() : SLPlus_BaseClass_Object
- __isset() : bool
- createstring_ShortcodeOutput() : string
- Process the slp_directory shortcode.
- filter_SQLStatements() : string
- Custom SQL command statements for the shortcode processor.
- get_instance() : SLPlus_BaseClass_Object
- Return an instance of the object which is also registered to the slplus global less the SLP_ part.
- initialize() : mixed
- Things to do at start.
- remove_sql_filter() : mixed
- Remove the SQL filter as needed.
- set_properties() : mixed
- Set our properties.
- sql_add_only_with_category() : string
- Add the only_with_category to the WHERE selection clause.
- sql_AddFilterBy() : string
- Add the filter_by to the WHERE selection clause.
- createstring_LandingPage() : string
- Create the landing page HTML.
- createstring_List() : string
- Create the list HTML for this shortcode.
- createstring_ListLink() : string
- Create an anchor text link for a directory entry.
- set_location_grouping() : mixed
- Group the directory output by a specific location property.
- translate_field_alias() : mixed
Properties
$addon
public
SLPPower
$addon
$addon
public
mixed
$addon
$alternate_groupby_field read-only
public
string
$alternate_groupby_field
The alternate group by field if the initial grouping field is blank.
$attribute_defaults read-only
public
array<string|int, string>
$attribute_defaults
The default attribute values - landing_page is an alias for locator_page
$attributes
public
array<string|int, string>
$attributes
The attributes as passed into the shortcode as name=>value pairs.
$attributes
public
mixed
$attributes
= array()
$content
public
string
$content
The content for the shortcode, the part between matching open/close shortcode pairs.
$content
public
mixed
$content
$filter_by read-only
public
string
$filter_by
$group_by read-only
public
string
$group_by
$landing_page read-only
public
SLP_Power_Directory_Landing_Page
$landing_page
The landing page processor.
$name
public
string
$name
The name used to call the shortcode.
$name
public
mixed
$name
$slplus
public
SLPlus
$slplus
$uses_slplus
public
bool
$uses_slplus
Set to true (default) if the object needs access to the SLPlus plugin object.
$slplus
protected
mixed
$slplus
$uses_slplus
protected
mixed
$uses_slplus
= \true
$alternate_groupby_field
private
mixed
$alternate_groupby_field
= ''
$attribute_defaults
private
mixed
$attribute_defaults
= array('by' => 'sl_state', 'if_blank_use' => '', 'filter_by' => '', 'landing_page' => '', 'locator_page' => '', 'locator_data' => '', 'only_with_category' => '', 'style' => 'list')
$filter_by
private
mixed
$filter_by
$group_by
private
mixed
$group_by
= 'sl_state'
$landing_page
private
mixed
$landing_page
$only_with_category
private
mixed
$only_with_category
Methods
__construct()
public
__construct([array<string|int, mixed> $options = array() ]) : mixed
Parameters
- $options : array<string|int, mixed> = array()
__get()
public
__get(string $property) : SLPlus_BaseClass_Object
Parameters
- $property : string
Return values
SLPlus_BaseClass_Object__isset()
public
__isset(string $property) : bool
Parameters
- $property : string
Return values
boolcreatestring_ShortcodeOutput()
Process the slp_directory shortcode.
public
createstring_ShortcodeOutput() : string
Attributes: o by = a store property to group data by o style = list, list_with_count, details
Return values
string —$HTML
filter_SQLStatements()
Custom SQL command statements for the shortcode processor.
public
filter_SQLStatements(string $command) : string
Parameters
- $command : string
Return values
stringget_instance()
Return an instance of the object which is also registered to the slplus global less the SLP_ part.
public
static get_instance([bool $no_global = false ][, mixed $params = array() ]) : SLPlus_BaseClass_Object
TODO: PHP7.4 and PHP8.0 the static instance variable returns an object matching $class TODO: PHP8.1 the static instance continually returns the FIRST object (SLP_Admin_Helper) every time -- it is like PHP8.1 static instance is bound to base_class-object versus the calling class object
Parameters
- $no_global : bool = false
-
set to true to skip assigning object to SLP global as a property.
- $params : mixed = array()
-
object init params
Return values
SLPlus_BaseClass_Objectinitialize()
Things to do at start.
public
initialize() : mixed
remove_sql_filter()
Remove the SQL filter as needed.
public
remove_sql_filter() : mixed
This is called from the parent whenever the specific shortcode processing is no longer needed. Allows for multiple shortcodes with different attributes to appear on the same page.
set_properties()
Set our properties.
public
set_properties([array<string|int, mixed> $options = array() ]) : mixed
Parameters
- $options : array<string|int, mixed> = array()
sql_add_only_with_category()
Add the only_with_category to the WHERE selection clause.
public
sql_add_only_with_category( $where) : string
Parameters
Return values
stringsql_AddFilterBy()
Add the filter_by to the WHERE selection clause.
public
sql_AddFilterBy( $where) : string
Parameters
Return values
stringcreatestring_LandingPage()
Create the landing page HTML.
private
createstring_LandingPage() : string
Return values
string —$HTML
createstring_List()
Create the list HTML for this shortcode.
private
createstring_List() : string
Return values
string —HTML
createstring_ListLink()
Create an anchor text link for a directory entry.
private
createstring_ListLink( $text, mixed $field_name[, mixed $url_data = null ][, mixed $url_field = null ]) : string
Parameters
- $text :
-
the text to show on the link
- $field_name : mixed
- $url_data : mixed = null
- $url_field : mixed = null
Return values
string —the HTML output string
set_location_grouping()
Group the directory output by a specific location property.
private
set_location_grouping() : mixed
translate_field_alias()
private
translate_field_alias(mixed $field_name) : mixed
Parameters
- $field_name : mixed