Okay, so I assume you know how to render assets?
Using smarty:
{asset name="MyAsset"}
Using php:
$this->RenderAsset('MyAsset');
So in your controller method you just need to add a string or Gdn_Module asset:
$this->AddAsset("MyAsset", "Hello World!");
or
$Module = new Gdn_SomeModule();
$this->AddAsset("MyAsset", $Module);
Answers
@Todd
Thanks for getting back so quickly!
- Spam
- Abuse
0 · Insightful Awesome LOL ·thanks @Todd. nice to see these pearls of wisdom every once in a while - it gives us inspiration :) and helps us understand the inner workings better.
factoid: Most questions have been previously answered, try the search box first, please provide your Vanilla version Number!
Peregrine's Addons - donations gladly accepted for "successful solutions" and addons - kind of like tipping a waiter at a restaurant
- Spam
- Abuse
0 · Insightful Awesome LOL ·I wasn't quite sure how to implement Todd's suggestion, but in searching how to, I found this code snippet which did what I was looking for
public function AddAsset($AssetContainer, $Asset, $AssetName = 'NEWASSETNAME') { if (is_object($AssetName)) { return FALSE; } else if ($AssetName == 'NEWASSETNAME') { $this->Assets[$AssetContainer][] = $Asset; } else { if (isset($this->Assets[$AssetContainer][$AssetName])) $this->Assets[$AssetContainer][$AssetName] .= $Asset; else $this->Assets[$AssetContainer][$AssetName] = $Asset; }which I added in to my plugin.php file.
- Spam
- Abuse
0 · Insightful Awesome LOL ·For future reference, Todd's solution was as simple as adding the line he suggested after
public function Base_Render_Before($Sender) {My plugin (modeled on the Adding some jQuery to a plugin example in the Wiki)
already had
public function Base_Render_Before($Sender) { $this->AddJsCss($Sender);so all I needed to do was add the lines there:
public function Base_Render_Before($Sender) { $this->AddJsCss($Sender); $this->AddAsset("MyAsset", "Category"); $this->AddAsset("MyAsset", "Table");- Spam
- Abuse
1 · Insightful 1Awesome LOL ·nice followup.
factoid: Most questions have been previously answered, try the search box first, please provide your Vanilla version Number!
Peregrine's Addons - donations gladly accepted for "successful solutions" and addons - kind of like tipping a waiter at a restaurant
- Spam
- Abuse
0 · Insightful Awesome LOL ·