Skip to content

Commit

Permalink
params bugfixes + insanity
Browse files Browse the repository at this point in the history
  • Loading branch information
kevinsguides committed Feb 2, 2024
1 parent 310a41a commit 26f6542
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 25 deletions.
49 changes: 27 additions & 22 deletions plugins/system/autoscrollspy/autoscrollspy.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@
use Joomla\Filter\OutputFilter;
use Joomla\CMS\Uri\Uri;
use Joomla\CMS\Helper\ModuleHelper;
use Joomla\CMS\Plugin\PluginHelper;
use Joomla\Registry\Registry;



class PlgSystemAutoScrollSpy extends CMSPlugin
Expand All @@ -18,15 +21,19 @@ class PlgSystemAutoScrollSpy extends CMSPlugin

public function onContentBeforeDisplay($context, &$article, &$params, $limitstart){

$params = $this->params;
$enable_scrollspy = $params->get('enable_scrollspy', 1);
$top_is_title = $params->get('top_is_title', 1);
$level1selector = $params->get('level1selector', 'h2');
$level2selector = $params->get('level2selector', 'h3');
$min_count = $params->get('min_count', 3);
$style = $params->get('style', 'default');
$render_location = $params->get('render_location', 'module');
$colors = $params->get('colors', 'asscolors-default');

//get params for plugin from plugin settings without new registery
$plugin = PluginHelper::getPlugin('system', 'autoscrollspy');
$this->params = new Registry($plugin->params);

$enable_scrollspy = $this->params->get('enable_scrollspy', 1);
$top_is_title = $this->params->get('top_is_title', 1);
$level1selector = $this->params->get('level1selector', 'h2');
$level2selector = $this->params->get('level2selector', 'h3');
$min_count = $this->params->get('min_count', 3);
$style = $this->params->get('style', 'default');
$render_location = $this->params->get('render_location', 'module');
$colors = $this->params->get('colors', 'asscolors-default');

$app = Factory::getApplication();
$wam = $app->getDocument()->getWebAssetManager();
Expand All @@ -38,12 +45,12 @@ public function onContentBeforeDisplay($context, &$article, &$params, $limitstar



$floatpanel_position = $params->get('floatpanel_position', 'left');
$floatpanel_width = $params->get('floatpanel_width', '200px');
$floatpanel_offset_top = $params->get('floatpanel_offset_top', '250px');
$floatpanel_paneltitle = $params->get('floatpanel_paneltitle', '');
$floatpanel_autocollapse_width = $params->get('floatpanel_autocollapse_width', '768');
$floatpanel_collapse_toggler_type = $params->get('floatpanel_collapse_toggler_type', 'fa-button');
$floatpanel_position = $this->params->get('floatpanel_position', 'left');
$floatpanel_width = $this->params->get('floatpanel_width', '200px');
$floatpanel_offset_top = $this->params->get('floatpanel_offset_top', '250px');
$floatpanel_paneltitle = $this->params->get('floatpanel_paneltitle', '');
$floatpanel_autocollapse_width = $this->params->get('floatpanel_autocollapse_width', '768');
$floatpanel_collapse_toggler_type = $this->params->get('floatpanel_collapse_toggler_type', 'fa-button');



Expand Down Expand Up @@ -80,12 +87,9 @@ public function onContentBeforeDisplay($context, &$article, &$params, $limitstar
}

//get contents of page
if($article->show_readmore == 1){
$article_text = $article->introtext.$article->fulltext;
}
else{

$article_text = $article->text;
}



$count = 0;
Expand Down Expand Up @@ -242,7 +246,7 @@ public function onContentBeforeDisplay($context, &$article, &$params, $limitstar
$dataStickyParentLevel = '';
if($render_location == 'modulesticky'){
$dataSticky = 'data-sticky="true" ';
$stickyParentLevelValue = $params->get('sticky_container_parent_level', 2);
$stickyParentLevelValue = $this->params->get('sticky_container_parent_level', 2);
$dataStickyParentLevel = 'data-sticky-parent-level="'.$stickyParentLevelValue.'" ';
}

Expand All @@ -264,7 +268,8 @@ public function onContentBeforeDisplay($context, &$article, &$params, $limitstar


//if render location is set to left, we will try to place it on the left side of a page in a styled cardlike container
if($render_location == 'floatpanel'){
//and count > min_count
if($render_location == 'floatpanel' && $count >= $min_count){

$styles = '';
$styles .= 'width:'.$floatpanel_width.';';
Expand Down
2 changes: 1 addition & 1 deletion plugins/system/autoscrollspy/autoscrollspy.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<license>GNU General Public License version 2 or later; see LICENSE.txt</license>
<authorEmail>[email protected]</authorEmail>
<authorUrl>https://kevinsguides.com</authorUrl>
<version>1.21</version>
<version>1.30</version>
<description>PLG_SYSTEM_AUTO_SCROLLSPY_XML_DESC</description>
<files>
<filename plugin="autoscrollspy">autoscrollspy.php</filename>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,6 @@ PLG_SYSTEM_AUTO_SCROLLSPY_FLOATPANEL_COLLAPSE_TOGGLER_TYPE_TEXTONLY = "Text Only
PLG_SYSTEM_AUTOSCROLLSPY_FLOATPANEL_COLLAPSETOGGLETEXT = "Article Contents"

PLG_SYSTEM_AUTO_SCROLLSPY_FIELDSTICKY_NOTE_CONFIG="Sticky Configuration Note"
PLG_SYSTEM_AUTO_SCROLLSPY_FIELDSTICKY_NOTE_CONFIG_DESC="This attempts to make the module sticky, so it sticks to the top of the page as user scrolls. This plugin has no idea what template you're using or how it works. So to achieve this, it sets a parent container of the module to position:sticky. The level selection number below is the number of levels between the scroll spy feature and the module container. Usually it is 1, 2, or 3. If none of these work, you may need to change template settings or hire help."
PLG_SYSTEM_AUTO_SCROLLSPY_FIELDSTICKY_NOTE_CONFIG_DESC="This <strong>attempts</strong> to make the module sticky, so it sticks to the top of the page as user scrolls. This plugin has no idea what template you're using or how it works. So to achieve this, it sets a parent container of the module to position:sticky. The level selection number below is the number of levels between the scroll spy feature and the module container. Usually it is 1, 2, or 3. If none of these work, you may need to change template settings or contract help."
PLG_SYSTEM_AUTO_SCROLLSPY_STICKY_CONTAINER_PARENT_LEVEL="Sticky Container Parent Level"
PLG_SYSTEM_AUTO_SCROLLSPY_STICKY_CONTAINER_PARENT_LEVEL_DESC="The number of levels between the scroll spy feature and the module container. Usually it is 1, 2, or 3. Change value, save plugin, refresh page on front end, and try again until it works."
PLG_SYSTEM_AUTO_SCROLLSPY_STICKY_CONTAINER_PARENT_LEVEL_DESC="The number of levels between the scroll spy feature and the module container. Usually it is 1, 2, or 3. Change value, save plugin, refresh page on front end, and try again until it hopefully works."

0 comments on commit 26f6542

Please sign in to comment.