Please upgrade here. These earlier versions are no longer being updated and have security issues.
HackerOne users: Testing against this community violates our program's Terms of Service and will result in your bounty being denied.
Unsetting LatestPostListModule
r0obert
✭
I used unset($Sender->Assets['Panel']['LatestPostListModule']); and it doesn't work. All other modules working though.
I'm on vanilla v2.1 and trying to unset LPL v1.5.3 on Basic Pages v2.1.3.
basicpages/settings/class.hooks.php code:
public function PageController_Render_Before($Sender) { $Page = $Sender->Data('PageData'); if($Page->UrlCode === $testpage) { unset($Sender->Assets['Panel']['NewDiscussionModule']); unset($Sender->Assets['Panel']['RecentActivityModule']); unset($Sender->Assets['Panel']['DiscussionsModule']); unset($Sender->Assets['Panel']['DiscussionFilterModule']); unset($Sender->Assets['Panel']['GuestModule']); unset($Sender->Assets['Panel']['LatestPostListModule']); } }
0
Comments
The
PageData
object has been renamed toPage
starting with Basic Pages 2.1.2. The$testpage
variable in your pasted code has to be defined or you can just put in the UrlCode directly likeif($Page->UrlCode === 'example-page') {
.In any case, from looking at the LatestPostList code, it looks like the module doesn't get loaded on the PageController at all.
I also recommend that you create a separate plugin or a ThemeHooks file for custom mods for your forum instead of modifying another addon's hooks file, so you can update addons easily without having to replace changes you made.
Add Pages to Vanilla with the Basic Pages app
@Shadowdare very interesting. It works with PageData but I guess it shouldn't in 2.1.3 right?
Also when I put $testpage it unsets the modules on all pages I create using BasicPages. Why is that?
Is there any other way of unsetting LatestPostList without using css?
PS: Btw could my other issue related to the endless refresh of pages be related with the fact that I only used css to hide modules instead of unset? (eg. display:none to all pretty much)
Here is an explanation of what happens when the code you posted is run:
At this point, PageData doesn't exist, so calling
$Sender->Data('PageData')
will return the default value returned by theData
method, which is an empty string''
.$Page->UrlCode
will returnnull
because the UrlCode property doesn't exist as$Page
is not an object.$testpage
is an undeclared variable so it has a value ofnull
. The condition$Page->UrlCode === $testpage
translates tonull === null
which is true, so the code within the if block will run.CSS rules like
display: none;
are not able to cause an infinite refresh, so that's probably not the issue.@hgtonight, is the LatestPostList module supposed to load up on all controllers?
Add Pages to Vanilla with the Basic Pages app
LPL has the ability to load the module on all controllers.
The reason it doesn't seem to work is because the LPL hook hasn't been run yet. When multiple plugins/applications/themehooks use the same event hook, they are fired off in alphabetical order based on their key.
Basicpages comes before LatestPostList.
Search first
Check out the Documentation! We are always looking for new content and pull requests.
Click on insightful, awesome, and funny reactions to thank community volunteers for their valuable posts.
@hgtonight so if the LPL hook hasn't been run yet, is there any way other than css to unset it?
.
I may not provide the completed solution you might desire, but I do try to provide honest suggestions to help you solve your issue.
to show on all frontend pages but a basic page.
in class.latertpost.plugin.php
if you wanted to prevent viewing on a specific page but all other basic pages
I may not provide the completed solution you might desire, but I do try to provide honest suggestions to help you solve your issue.
Works, thanks!
I'll just leave this here: one way to avoid modifying addons and the Vanilla core code in order to upgrade those addons and the core easier is to create a plugin with a name that starts with the letter 'z' or something like that.
Add Pages to Vanilla with the Basic Pages app