Welcome to the Question2Answer Q&A. There's also a demo if you just want to try it out.

Can I make a new widget on a specific custom page module?

+1 vote
asked Jun 4, 2012 in Plugins by anonymous
I wrote a widget, and make the method "allow_template" return true when $template is equal to "custom", then i select then checkbox of the widget to be displayed on my custom page, However, my custom page can't display this widget. why?
commented Jun 15, 2012 by gidgreen
Can you make it appear on any other pages? If not, it may be there is some problem with the widget not related to custom pages.

2 Answers

0 votes
answered Jul 26, 2012 by Fox Cameron

qa-page-admin-widgets.php file contains an array named: $templatelangkeys that is instantiated on line 72 (in my source).

$templatelangkeys contains a list of all avaliable pages (or "template" as they're referred to) that is displayed on the Admin -> Layout -> Add Widget page when selecting what template your widget is permitted to appear on.

You also must allow the widget plugin to display on this template through the widget's allow_template() method. (as you have noticed)

Important note:
I haven't yet found a method to register a new template that references the custom page plugin (and it doesn't appear to do so automativally). If a method does not exist (I hven't found one) then you will need to hand edit the $templatelangkeys array when you want a custom widget plugin on a custom page.

0 votes
answered Jul 30, 2012 by Fox Cameron