Skip to content

Commit 3e21c66

Browse files
author
Kevin Olson
committed
update v1.21
1 parent 9b492d8 commit 3e21c66

File tree

4 files changed

+38
-4
lines changed

4 files changed

+38
-4
lines changed

modules/mod_autoscrollspy/mod_autoscrollspy.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,5 +6,12 @@
66
*/
77

88
defined ( '_JEXEC' ) or die;
9+
use Joomla\CMS\Factory;
910

11+
12+
//check if we are on a com_content article view
13+
if (Factory::getApplication()->input->get('option') == 'com_content' && Factory::getApplication()->input->get('view') == 'article'):
1014
?>
15+
<div id="autoscrollspybykg">
16+
</div>
17+
<?php endif; ?>

plugins/system/autoscrollspy/autoscrollspy.php

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414

1515
class PlgSystemAutoScrollSpy extends CMSPlugin
1616
{
17+
protected $html;
1718

1819
public function onBeforeRender(){
1920

@@ -80,6 +81,7 @@ public function onBeforeRender(){
8081
if(ModuleHelper::isEnabled('mod_autoscrollspy') == false && $render_location != 'floatpanel'){
8182
return;
8283
}
84+
8385
//get contents of page
8486
$article = Factory::getApplication()->getDocument()->getBuffer('component');
8587

@@ -236,6 +238,7 @@ public function onBeforeRender(){
236238
if( $render_location == 'module' || $render_location == 'modulesticky' ){
237239
//replace the contents of the module with the html
238240
$module->content = $html;
241+
239242
}
240243

241244
//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
@@ -285,10 +288,22 @@ public function onBeforeRender(){
285288
//update component buffer
286289
Factory::getApplication()->getDocument()->setBuffer($article, 'component');
287290

288-
289-
291+
$this->html = $html;
290292

291293
}
292294

295+
public function onAfterRender()
296+
297+
{
298+
$app = Factory::getApplication();
299+
$buffer = $app->getBody();
300+
301+
// Replace module output based on folder name
302+
$buffer = preg_replace('/<div id="autoscrollspybykg">(.*?)<\/div>/s', $this->html, $buffer);
303+
304+
$app->setBody($buffer);
305+
}
306+
307+
293308

294309
}

plugins/system/autoscrollspy/autoscrollspy.xml

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,11 @@
33
<name>plg_system_autoscrollspy</name>
44
<author>Kevin Olson</author>
55
<creationDate>2023-04</creationDate>
6-
<copyright>(C) 2023 Kevin Olson.</copyright>
6+
<copyright>(C) 2024 Kevin Olson.</copyright>
77
<license>GNU General Public License version 2 or later; see LICENSE.txt</license>
88
<authorEmail>[email protected]</authorEmail>
99
<authorUrl>https://kevinsguides.com</authorUrl>
10-
<version>1.2</version>
10+
<version>1.21</version>
1111
<description>PLG_SYSTEM_AUTO_SCROLLSPY_XML_DESC</description>
1212
<files>
1313
<filename plugin="autoscrollspy">autoscrollspy.php</filename>
@@ -123,6 +123,15 @@
123123
<option value="modulesticky">Module Force Sticky*</option>
124124
<option value="floatpanel">Floating Panel</option>
125125
</field>
126+
127+
<field
128+
name="fieldsticky_note"
129+
type="note"
130+
label="PLG_SYSTEM_AUTO_SCROLLSPY_FIELDSTICKY_NOTE"
131+
description="PLG_SYSTEM_AUTO_SCROLLSPY_FIELDSTICKY_NOTE_DESC"
132+
showon="render_location:modulesticky"
133+
/>
134+
126135
<field
127136
name="floatpanel_position"
128137
type="list"

plugins/system/autoscrollspy/language/en-GB/plg_system_autoscrollspy.ini

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,4 +34,7 @@ PLG_SYSTEM_AUTO_SCROLLSPY_FLOATPANEL_COLLAPSE_TOGGLER_TYPE_DESC = "It will eithe
3434
PLG_SYSTEM_AUTO_SCROLLSPY_FLOATPANEL_COLLAPSE_TOGGLER_TYPE_TEXTONLY = "Text Only (no icon)"
3535
PLG_SYSTEM_AUTOSCROLLSPY_FLOATPANEL_COLLAPSETOGGLETEXT = "Article Contents"
3636

37+
PLG_SYSTEM_AUTO_SCROLLSPY_FIELDSTICKY_NOTE="Sticky Module Notice"
38+
PLG_SYSTEM_AUTO_SCROLLSPY_FIELDSTICKY_NOTE_DESC="This may not work on every template. If it doesn't work, you can try float panel, or you can see if your template has a way to manually enable sticky modules."
39+
3740

0 commit comments

Comments
 (0)