On 1/10/06, Kim Ryan <[EMAIL PROTECTED]> wrote:
> OK, will explain this more clearly. I want to add some custom variables
> to an existing template, and am using the approach of adding a sub and
> exporting it:
>
> sub todays_list : Exported {
>     my ($self, $r ) = @_;
>     my $some_var = 'some value';
>     $r->objects( $self->search( some_var =>  $some_var->x) );
>     $r->template('list');
> }
>
> That is all fine, except I can't compile because I get and Invalid CODE error
> when the compiler see ': Exported.' The suggested work arounds of wrapping
> BEGIN {} around  the sub or calling  the sub last don't work.
>

Ahh. I see. A new name and spin on an old template.   One thing I see
that may not work how you expect is "objects" takes an array ref not
an array or iterator. So i think you need to wrap that search in [].

Regarding your error, do you have other subs with the Exported
attribute in that file?  If you comment out your new sub does it work?


pjs


-------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc. Do you grep through log files
for problems?  Stop!  Download the new AJAX search engine that makes
searching your log files as easy as surfing the  web.  DOWNLOAD SPLUNK!
http://ads.osdn.com/?ad_idv37&alloc_id865&op=click
_______________________________________________
Maypole-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/maypole-users

Reply via email to