PHP Question
R_J
Admin
I was thinking about creating a little plugin that makes navigating through the long list of plugins easier by providing an alphabetical shortcut list. This is what I started with:
class PluginNavigatorPlugin extends Gdn_Plugin {
public function SettingsController_BeforeRenderAsset_Handler($Sender) {
// stop if not Content of Plugins section
if (($Sender->EventArguments['AssetName'] != 'Content') || (substr($Sender->SelfUrl,0, 16) != 'settings/plugins')) {
return;
}
$Content = $Sender->Assets['Content'];
// some regex magic here
$ContentNew = preg_replace('/(< div class="Info">)/', '$1Index: A B C D E F...< /div>$1', $Content);
$Sender->Assets['Content'] = $ContentNew;
}
}
Looks clean and easy but does not do anything 
If I look at where the event is fired, I see this (class.controller.php):
public function RenderAsset($AssetName) {
$Asset = $this->GetAsset($AssetName);
$this->EventArguments['AssetName'] = $AssetName;
$this->FireEvent('BeforeRenderAsset');
//$LengthBefore = ob_get_length();
if(is_string($Asset)) {
echo $Asset;
...
So I would have to change the var $Asset in the scope of the function RenderAsset. Is this possible?
0


Answers
No.
There are other approaches to do what you want to do, but as far as I know, there is no way to access variables out of scope.
EDIT: Clever regex, btw.
Yes, I've thought about js and later on I remembered I could simply create a custom view. I think I simply create such a view. Thanks for answering even simple php questions
edited out.
back in again.
the dreaded reflection methods.
But it was also true
ok edited back in.
But perhaps I wish I didn't.