Search the web
Sign In
New User? Sign Up
mt-dev · Movable Type Developers
? Already a member? Sign in to Yahoo!

Yahoo! Groups Tips

Did you know...
Want to share photos of your group with the world? Add a group photo to Flickr.

Best of Y! Groups

   Check them out and nominate your group.
Having problems with message search? Fill out this form to ensure your group is one of the first to be migrated to the new message search system.

Messages

  Messages Help
Advanced
Messages 2083 - 2112 of 2112   Oldest  |  < Older  |  Newer >  |  Newest
Messages: Show Message Summaries   (Group by Topic) Sort by Date ^  
#2083 From: Mark Paschal <mark@...>
Date: Wed Aug 20, 2008 5:20 pm
Subject: Re: Is it possible to have an ActionStream plugin execute code instead of the scraper or xpath functionality?
markpaaasc
Offline Offline
Send Email Send Email
 
Michael Thomsen wrote:
> I'm trying to write a plugin for ActionStream which adds support for
> Slashdot, but to do that I need more complex functionality than what
> scraper or xpath provide in ActionStreams. Is it possible for me to
> have the action_stream in a config.yaml file for the plugin execute a
> Perl function instead of running the scraper or doing xpath?

Yes, see "Custom collectors" in the recipe guide provided with the
development version of the plugin (most of it applies to 1.0 as well):

<http://code.sixapart.com/svn/mtplugins/trunk/ActionStreams/plugins/ActionStream\
s/doc/recipe-guide.txt>

See the plugin's implementation of the Vox favorites stream for an
example. If you need only clean settings up after xpath or scraper
rules, also check out the "Cleaning up after your stream" and "Stream
recipe callback reference" sections. There are several examples in the
AS plugin.

HTH.


Mark Paschal
mark@...

#2084 From: jesse <jessedp@...>
Date: Thu Aug 28, 2008 5:02 pm
Subject: Upgrading custom object for my plugin
jessedp23
Offline Offline
Send Email Send Email
 
Hello all. I'm putting out an updated version of our MT plugin and am having some issues with the upgrade scripts b/c I need to up the schema version. For the DB table change, I "simply" want to drop one column (a password field) and add another (an api key field). Because of that, I need to do something like this:

* add the new column to the table
* for each Object, retrieve it and:
    - login to our web service to get the proper api_key
    - update the new column with the key
* drop the column from the table

Honestly, I sincerely doubt anyone using this has actually set this up on more than one blog, so even adding/dropping the column during the "for each" would likely be fine, though I would rather do it right just in case.

I've been trying to accomplish this using the "upgrade_functions" param when I init my plugin as shown here:

    http://www.movabletype.org/documentation/developer/movable-type-registry-reference.html
    
Of course I've also updated my Custom Object's "install_properties", removing the one field & adding the other.

So far the upgrade script is running, but this is all I see:
---
    * Upgrading table for mailchimp_list records...
    * Plugin 'MailChimp Subscribe Form' upgraded successfully to version 1.1 (schema version 1.1).
---
From what I can tell, my "updater" "code" is not being run at all. When I check the db table, I can see that the new column is added, but the old column is not being removed. Given that result, I'm pretty sure I could hack in some code to clean things up in my plugin code, but I'd really rather do it the right way.

I've really tried digging through some other plugins and the core MT code, and am just not having any luck figuring this out.

Oh, also, I'm running MT 4.1.

Any help or suggestions anyone can provide would be greatly appreciated.

thanks,


jesse


#2085 From: "Mark Carey" <mtpronet@...>
Date: Thu Aug 28, 2008 5:41 pm
Subject: Re: Upgrading custom object for my plugin
bsakamano
Offline Offline
Send Email Send Email
 
Jesse,

Its hard to be specific since you haven't posted any code but...

I don't think the MT api will remove the column.  It is pretty good
add schema changes to add or modify existing columns, but I don't
think there is any logic in there to remove a column (but I am not
100% sure).

That said, since the new column is getting added, the remaining item is:

> * for each Object, retrieve it and:
>     - login to our web service to get the proper api_key
>     - update the new column with the key

And for this, your are correct, an upgrade function is the way to go.
I can't comment on what isn't working for you, of course.

Here's an example from one my plugins:

snippet from my .pl file, to register the upgrade function"

'upgrade_functions' => {
   'import_images' => {
     version_limit => 1.231,   # runs for schema_version < 1.231  --
plugin version 1.5x
     updater => {
       type => 'author',
       label => 'Importing author photos...',
       condition => sub { !$_[0]->userpic_asset_id },
       code => '$UserProfile::UserProfiles::Pro::Util::import_images',
     }
   },
},

and the function itself:

sub import_images {
	 my ($author) = @_;
	 return if $author->userpic_asset_id;

         ...code here to import image, create asset, etc. (you api
fetching stuff would go here)

	 # now update the object
	 $author->userpic_asset_id($asset->id)
        	 or MT->log("Error adding asset to author: " . $author->errstr);
	 $author->save;
}

As you work on it, try to log any errors to the MT activity log, or to
STDERR, as that can help identify issues along the way...

Hope this helps,

Mark



On Thu, Aug 28, 2008 at 2:02 PM, jesse <jessedp@...> wrote:


> Hello all. I'm putting out an updated version of our MT plugin and am having
> some issues with the upgrade scripts b/c I need to up the schema version.
> For the DB table change, I "simply" want to drop one column (a password
> field) and add another (an api key field). Because of that, I need to do
> something like this:
>
> * add the new column to the table
> * for each Object, retrieve it and:
>     - login to our web service to get the proper api_key
>     - update the new column with the key
> * drop the column from the table
>
> Honestly, I sincerely doubt anyone using this has actually set this up on
> more than one blog, so even adding/dropping the column during the "for each"
> would likely be fine, though I would rather do it right just in case.
>
> I've been trying to accomplish this using the "upgrade_functions" param when
> I init my plugin as shown here:
>
>
>
http://www.movabletype.org/documentation/developer/movable-type-registry-referen\
ce.html
>
> Of course I've also updated my Custom Object's "install_properties",
> removing the one field & adding the other.
>
> So far the upgrade script is running, but this is all I see:
> ---
>     * Upgrading table for mailchimp_list records...
>     * Plugin 'MailChimp Subscribe Form' upgraded successfully to version 1.1
> (schema version 1.1).
> ---
> From what I can tell, my "updater" "code" is not being run at all. When I
> check the db table, I can see that the new column is added, but the old
> column is not being removed. Given that result, I'm pretty sure I could hack
> in some code to clean things up in my plugin code, but I'd really rather do
> it the right way.
>
> I've really tried digging through some other plugins and the core MT code,
> and am just not having any luck figuring this out.
>
> Oh, also, I'm running MT 4.1.
>
> Any help or suggestions anyone can provide would be greatly appreciated.
>
> thanks,
>
>
> jesse
>
>

#2086 From: jesse <jessedp@...>
Date: Thu Aug 28, 2008 6:15 pm
Subject: Re: Upgrading custom object for my plugin
jessedp23
Offline Offline
Send Email Send Email
 
Thanks for the reply, Mark. Sorry for not posting code, but I had literally followed the example on the page I referenced to the tee. Anywho, here's my "upgrade_functions" setup:


upgrade_functions => {
    'upgrade_to_1_1' => {
        version_limit => 1.001, # schema 1.0001, plugin v1.1
        updater => {
            type => 'list',
            label => 'Updating MailChimp ListDetails...',
            condition => sub { 1; },
            code => '$MailChimp::MailChimp::Utils::upgrade_to_1_1'
        },
    },
}

When I wrote 1st, it was:
code=> sub { //do stuff }

Just to follow the way you did it, I split off the code into another module. One thing I meant to ask the 1st time is what "type" is supposed to be. I've randomly swapped it around with different things - "list" is there now b/c it is the name of the object type the custom object I am messing with is defined as:
object_types   => {
    'list' => 'MailChimp::ListDetails',
},

 I did stick some print STDERR lines in the function that references, but don't see anything occur.

On that note, it is completely possible that I'm missing something that should be logged or debugged - b/c I can't find *anything* anywhere. I remember getting stack traces & such on screen when I was writing this the 1st time, and still have DebugMode set to 3, but I don't see anything anywhere. I've actually had to add code back in line-by-line to see what caused the plugin to fail to load, which is wonky and tedious. Any suggestions for that would be wonderful. I'd love to just have it dumped in a file somewhere that I can tail.
 
thanks,

jesse


On Thu, Aug 28, 2008 at 13:41, Mark Carey <mtpronet@...> wrote:

Jesse,

Its hard to be specific since you haven't posted any code but...

I don't think the MT api will remove the column. It is pretty good
add schema changes to add or modify existing columns, but I don't
think there is any logic in there to remove a column (but I am not
100% sure).

That said, since the new column is getting added, the remaining item is:



> * for each Object, retrieve it and:
> - login to our web service to get the proper api_key
> - update the new column with the key

And for this, your are correct, an upgrade function is the way to go.
I can't comment on what isn't working for you, of course.

Here's an example from one my plugins:

snippet from my .pl file, to register the upgrade function"

'upgrade_functions' => {
'import_images' => {
version_limit => 1.231, # runs for schema_version < 1.231 --
plugin version 1.5x
updater => {
type => 'author',
label => 'Importing author photos...',
condition => sub { !$_[0]->userpic_asset_id },
code => '$UserProfile::UserProfiles::Pro::Util::import_images',
}
},
},

and the function itself:

sub import_images {
my ($author) = @_;
return if $author->userpic_asset_id;

...code here to import image, create asset, etc. (you api
fetching stuff would go here)

# now update the object
$author->userpic_asset_id($asset->id)
or MT->log("Error adding asset to author: " . $author->errstr);
$author->save;
}

As you work on it, try to log any errors to the MT activity log, or to
STDERR, as that can help identify issues along the way...

Hope this helps,

Mark


On Thu, Aug 28, 2008 at 2:02 PM, jesse <jessedp@...> wrote:

> Hello all. I'm putting out an updated version of our MT plugin and am having
> some issues with the upgrade scripts b/c I need to up the schema version.
> For the DB table change, I "simply" want to drop one column (a password
> field) and add another (an api key field). Because of that, I need to do
> something like this:
>
> * add the new column to the table
> * for each Object, retrieve it and:
> - login to our web service to get the proper api_key
> - update the new column with the key
> * drop the column from the table
>
> Honestly, I sincerely doubt anyone using this has actually set this up on
> more than one blog, so even adding/dropping the column during the "for each"
> would likely be fine, though I would rather do it right just in case.
>
> I've been trying to accomplish this using the "upgrade_functions" param when
> I init my plugin as shown here:
>
>
> http://www.movabletype.org/documentation/developer/movable-type-registry-reference.html
>
> Of course I've also updated my Custom Object's "install_properties",
> removing the one field & adding the other.
>
> So far the upgrade script is running, but this is all I see:
> ---
> * Upgrading table for mailchimp_list records...
> * Plugin 'MailChimp Subscribe Form' upgraded successfully to version 1.1
> (schema version 1.1).
> ---
> From what I can tell, my "updater" "code" is not being run at all. When I
> check the db table, I can see that the new column is added, but the old
> column is not being removed. Given that result, I'm pretty sure I could hack
> in some code to clean things up in my plugin code, but I'd really rather do
> it the right way.
>
> I've really tried digging through some other plugins and the core MT code,
> and am just not having any luck figuring this out.
>
> Oh, also, I'm running MT 4.1.
>
> Any help or suggestions anyone can provide would be greatly appreciated.
>
> thanks,
>
>
> jesse
>
>


#2087 From: "Mark Carey" <mtpronet@...>
Date: Thu Aug 28, 2008 7:25 pm
Subject: Re: Upgrading custom object for my plugin
bsakamano
Offline Offline
Send Email Send Email
 
On Thu, Aug 28, 2008 at 3:15 PM, jesse <jessedp@...> wrote:
>"list" is there now b/c
> it is the name of the object type the custom object I am messing with is
> defined as:
> object_types   => {
>     'list' => 'MailChimp::ListDetails',
> },

This is correct, it must match the object type you have defined.  Each
object passing the "condition" will get passed to the "code" function,
so your first line might be

my ($list) = @_;

...and you can manipulate and save the object from there.

> Any
> suggestions for that would be wonderful. I'd love to just have it dumped in
> a file somewhere that I can tail.

You could try Jay Allens log4mt tool [1].  I haven't tried it myself
yet, but I plan to, as it sounds quite helpful.

-Mark

[1] https://trac.endevver.com/movabletype/wiki/plugins/log4mt

#2088 From: jesse <jessedp@...>
Date: Thu Aug 28, 2008 7:49 pm
Subject: Re: Upgrading custom object for my plugin
jessedp23
Offline Offline
Send Email Send Email
 
Turns out I wasn't paying attention to the ever so important placement of a closing brace, so my entire upgrade_functions section was not in the registry section. Oops.

On a side note, logging to stderr works out perfectly b/c I can just tail my apache error log to see what's happening. I imagine I'll be fine from here on out.

thanks again for the help, Mark.


jesse

On Thu, Aug 28, 2008 at 15:25, Mark Carey <mtpronet@...> wrote:

On Thu, Aug 28, 2008 at 3:15 PM, jesse <jessedp@...> wrote:
>"list" is there now b/c
> it is the name of the object type the custom object I am messing with is
> defined as:
> object_types => {
> 'list' => 'MailChimp::ListDetails',
> },

This is correct, it must match the object type you have defined. Each
object passing the "condition" will get passed to the "code" function,
so your first line might be

my ($list) = @_;

...and you can manipulate and save the object from there.


> Any
> suggestions for that would be wonderful. I'd love to just have it dumped in
> a file somewhere that I can tail.

You could try Jay Allens log4mt tool [1]. I haven't tried it myself
yet, but I plan to, as it sounds quite helpful.

-Mark

[1] https://trac.endevver.com/movabletype/wiki/plugins/log4mt


#2089 From: "Michael Thomsen" <mikerthomsen@...>
Date: Tue Sep 2, 2008 8:25 pm
Subject: How should I initialize a template context?
codemonkeyov...
Offline Offline
Send Email Send Email
 
I have a template file in a plugin that I need to compile and write
the HTML to a separate directory. I've seen the following way to
initialize a MT::Template::Context object to pass to
MT::Template->build, but it causes an error. This is use in the docs:

my $ctx = MT::Template::Context->new();

Yet when I run that in a callback method attached to MT::Comment, I
get the following error in my error log:

died with: Can't call method "server_offset" on an undefined value at
lib/MT/Template/ContextHandlers.pm line 10075.

All I need to do is load the template, build it to HTML, and write it
to a file. How should I setup the Context so that I can do this?

#2090 From: Timothy Appnel <tim@...>
Date: Tue Sep 2, 2008 10:28 pm
Subject: Re: How should I initialize a template context?
tappnel
Offline Offline
Send Email Send Email
 
What version are you working with?

Sent from my iPhone

On Sep 2, 2008, at 16:25, "Michael Thomsen" <mikerthomsen@...> wrote:

I have a template file in a plugin that I need to compile and write
the HTML to a separate directory. I've seen the following way to
initialize a MT::Template::Context object to pass to
MT::Template->build, but it causes an error. This is use in the docs:

my $ctx = MT::Template::Context->new();

Yet when I run that in a callback method attached to MT::Comment, I
get the following error in my error log:

died with: Can't call method "server_offset" on an undefined value at
lib/MT/Template/ContextHandlers.pm line 10075.

All I need to do is load the template, build it to HTML, and write it
to a file. How should I setup the Context so that I can do this?


#2091 From: "Michael Thomsen" <mikerthomsen@...>
Date: Tue Sep 2, 2008 11:46 pm
Subject: Re: How should I initialize a template context?
codemonkeyov...
Offline Offline
Send Email Send Email
 
4.21 Pro

On Tue, Sep 2, 2008 at 6:28 PM, Timothy Appnel <tim@...> wrote:
> What version are you working with?
>
> Sent from my iPhone
> On Sep 2, 2008, at 16:25, "Michael Thomsen" <mikerthomsen@...> wrote:
>
> I have a template file in a plugin that I need to compile and write
> the HTML to a separate directory. I've seen the following way to
> initialize a MT::Template::Context object to pass to
> MT::Template->build, but it causes an error. This is use in the docs:
>
> my $ctx = MT::Template::Context->new();
>
> Yet when I run that in a callback method attached to MT::Comment, I
> get the following error in my error log:
>
> died with: Can't call method "server_offset" on an undefined value at
> lib/MT/Template/ContextHandlers.pm line 10075.
>
> All I need to do is load the template, build it to HTML, and write it
> to a file. How should I setup the Context so that I can do this?
>
>

#2092 From: "Mark Carey" <mtpronet@...>
Date: Wed Sep 3, 2008 12:17 pm
Subject: Re: How should I initialize a template context?
bsakamano
Offline Offline
Send Email Send Email
 
If you already have a template object (from the db) loaded, you can do:

my $ctx = $tmpl->context;

The error is because your context does not include a blog context --
it can't find $blog->server_offset because the blog is undefined.  I
believe that using the method above will inherit the blog context of
the template in question, this avoiding this error.

-Mark

On Tue, Sep 2, 2008 at 5:25 PM, Michael Thomsen <mikerthomsen@...> wrote:
> I have a template file in a plugin that I need to compile and write
> the HTML to a separate directory. I've seen the following way to
> initialize a MT::Template::Context object to pass to
> MT::Template->build, but it causes an error. This is use in the docs:
>
> my $ctx = MT::Template::Context->new();
>
> Yet when I run that in a callback method attached to MT::Comment, I
> get the following error in my error log:
>
> died with: Can't call method "server_offset" on an undefined value at
> lib/MT/Template/ContextHandlers.pm line 10075.
>
> All I need to do is load the template, build it to HTML, and write it
> to a file. How should I setup the Context so that I can do this?
>
> ------------------------------------
>
> Yahoo! Groups Links
>
>
>
>

#2093 From: "Michael Thomsen" <mikerthomsen@...>
Date: Wed Sep 3, 2008 12:39 pm
Subject: Re: How should I initialize a template context?
codemonkeyov...
Offline Offline
Send Email Send Email
 
Hmmm, see I'm loading the template from a plugin directory, not the
database. Do I need to register the tmpl file in the registry to make
this easier?

On Wed, Sep 3, 2008 at 8:17 AM, Mark Carey <mtpronet@...> wrote:
> If you already have a template object (from the db) loaded, you can do:
>
> my $ctx = $tmpl->context;
>
> The error is because your context does not include a blog context --
> it can't find $blog->server_offset because the blog is undefined. I
> believe that using the method above will inherit the blog context of
> the template in question, this avoiding this error.
>
> -Mark
>
> On Tue, Sep 2, 2008 at 5:25 PM, Michael Thomsen <mikerthomsen@...>
> wrote:
>> I have a template file in a plugin that I need to compile and write
>> the HTML to a separate directory. I've seen the following way to
>> initialize a MT::Template::Context object to pass to
>> MT::Template->build, but it causes an error. This is use in the docs:
>>
>> my $ctx = MT::Template::Context->new();
>>
>> Yet when I run that in a callback method attached to MT::Comment, I
>> get the following error in my error log:
>>
>> died with: Can't call method "server_offset" on an undefined value at
>> lib/MT/Template/ContextHandlers.pm line 10075.
>>
>> All I need to do is load the template, build it to HTML, and write it
>> to a file. How should I setup the Context so that I can do this?
>>
>> ------------------------------------
>>
>> Yahoo! Groups Links
>>
>>
>>
>>
>

#2094 From: jesse <jessedp@...>
Date: Wed Sep 3, 2008 3:55 pm
Subject: testing 2 variables with mt:loop and mt:if tags
jessedp23
Offline Offline
Send Email Send Email
 
I have an object being passed to a template and can access it's fields just fine. The object represents a user-selected "list", of which there may be many. I wanted to display these in a select box so a different one can be easily changed. Obviously I'd like to set the "selected" option on the proper list entry. Here's the code I've been trying to get working:

------------------------------------------------
<mt:SetVar name="lid" value="@list-list_id">
<select name="mc_list_id" size="3" style="min-width:200px;">
<mt:loop name="lists" sort_by="name">
     <option value='<$mt:var name="id"$>' <mt:if name="id" eq="$lid"> selected </mt:if> > <$mt:var name="name"$> </option>
</mt:loop>
</select>
------------------------------------------------
The piece that I can't get working is that mt:if on line 4. What I need to do is compare the var I'm setting on line one with the "id" var that I'm using as the option value on line 4. I've also tried several variations of things in the mt:if "eq" param to no avail instead of using mt:setvar.

Am I going about this in the correct way? Is this possible?

thanks,


jesse

#2095 From: Su <hamletcomplex@...>
Date: Wed Sep 3, 2008 4:03 pm
Subject: Re: testing 2 variables with mt:loop and mt:if tags
hamletcomplex
Offline Offline
Send Email Send Email
 
On Wed, Sep 3, 2008 at 10:55 AM, jesse <jessedp@...> wrote:
>      <option value='<$mt:var name="id"$>' <mt:if name="id" eq="$lid">

In this line you seem to be creating $id but not setting it to
anything, and then testing if it equals $lid. That obviously won't
because you never gave $id a value.

Is there some other place further up/down where you /do/ assign
something to $id?

#2096 From: jesse <jessedp@...>
Date: Wed Sep 3, 2008 4:10 pm
Subject: Re: testing 2 variables with mt:loop and mt:if tags
jessedp23
Offline Offline
Send Email Send Email
 
Su, on the line you referenced, "id" is coming from the "lists" object (it maybe a hash) used in my mt:loop. Also notice that it's a "var", not a "setvar". That's just printing the "id" as the value for that option tag - it works fine.

The "lid" I am trying to compare to came from the 1st line of the original code. To be clear, if I try to print "list-list_id", using mt:var, it works just fine. Now I just need to compare that to "id" inside my mt:loop

 Since it got dropped in the reply, here it is again:
---------------------
<mt:SetVar name="lid" value="@list-list_id">
<select name="mc_list_id" size="3" style="min-width:200px;">
<mt:loop name="lists" sort_by="name">
    <option value='<$mt:var name="id"$>' <mt:if name="id" eq="$lid"> selected </mt:if> > <$mt:var name="name"$> </option>
</mt:loop>
</select>
---------------------

thanks,


jesse


On Wed, Sep 3, 2008 at 12:03, Su <hamletcomplex@...> wrote:

On Wed, Sep 3, 2008 at 10:55 AM, jesse <jessedp@...> wrote:
> <option value='<$mt:var name="id"$>' <mt:if name="id" eq="$lid">

In this line you seem to be creating $id but not setting it to
anything, and then testing if it equals $lid. That obviously won't
because you never gave $id a value.

Is there some other place further up/down where you /do/ assign
something to $id?


#2097 From: "Mark Carey" <mtpronet@...>
Date: Wed Sep 3, 2008 5:31 pm
Subject: Re: How should I initialize a template context?
bsakamano
Offline Offline
Send Email Send Email
 
On Wed, Sep 3, 2008 at 9:39 AM, Michael Thomsen <mikerthomsen@...> wrote:
> Hmmm, see I'm loading the template from a plugin directory, not the
> database.

In that case, you were probably on the right track originally, but you
need add the blog context manually:

my $ctx = MT::Template::Context->new();
$ctx->{__stash}{'blog'} = $blog;

(of course, prior to this you need to load the blog object into $blog)

-Mark

#2098 From: "Michael Thomsen" <mikerthomsen@...>
Date: Wed Sep 3, 2008 5:54 pm
Subject: Re: How should I initialize a template context?
codemonkeyov...
Offline Offline
Send Email Send Email
 
Ok, that works. How do I pass it variable values so that tags like
<mt:var and <mt:loop can get populated? What I have right now is:

$params{items} = \@commentData;
	 $params{commenter_author_name} = $new->author();
	 my @blog = MT::Blog->load({id => $new->blog_id()});
	 my $ctx = MT::Template::Context->new();
	 $ctx->{__stash}{'blog'} = $blog[0];
	 $ctx->{__stash}{commenter_author_name} = $new->author();

	 my $output = $template->build($ctx, \%params);

On Wed, Sep 3, 2008 at 1:31 PM, Mark Carey <mtpronet@...> wrote:
> On Wed, Sep 3, 2008 at 9:39 AM, Michael Thomsen <mikerthomsen@...>
> wrote:
>> Hmmm, see I'm loading the template from a plugin directory, not the
>> database.
>
> In that case, you were probably on the right track originally, but you
> need add the blog context manually:
>
> my $ctx = MT::Template::Context->new();
> $ctx->{__stash}{'blog'} = $blog;
>
> (of course, prior to this you need to load the blog object into $blog)
>
> -Mark
>

#2099 From: jesse <jessedp@...>
Date: Wed Sep 3, 2008 6:04 pm
Subject: Re: How should I initialize a template context?
jessedp23
Offline Offline
Send Email Send Email
 
Michael, you should be able to just shove any other variables you want into the $params hash you have setup there.

I'm not real great with my perl and what syntax is equivalent, but what works for me is like this:

my $pars = { 'error_msg'=>$error_msg, 'success_msg'=>$success_msg };
$params->{content}=$my_content;
$params->{lists} = \@lists;
my $output = $template->build($ctx, $params);

not certain if:
$params{content} = $my_content;

is equivalent. I've fudged this a bit b/c I'm actually calling this when I build the template (just a slightly different way)
$app->build_page( $tmpl , $pars );

But I'm pretty sure they build & build_page have the same method signatures.

Also, I included the "lists" param above b/c I am using that in mt:loop and it works fine (well, except for the other open question I sent this morning).


jesse

On Wed, Sep 3, 2008 at 13:54, Michael Thomsen <mikerthomsen@...> wrote:

Ok, that works. How do I pass it variable values so that tags like
<mt:var and <mt:loop can get populated? What I have right now is:

$params{items} = \@commentData;
$params{commenter_author_name} = $new->author();
my @blog = MT::Blog->load({id => $new->blog_id()});
my $ctx = MT::Template::Context->new();
$ctx->{__stash}{'blog'} = $blog[0];
$ctx->{__stash}{commenter_author_name} = $new->author();

my $output = $template->build($ctx, \%params);

On Wed, Sep 3, 2008 at 1:31 PM, Mark Carey <mtpronet@...> wrote:
> On Wed, Sep 3, 2008 at 9:39 AM, Michael Thomsen <mikerthomsen@...>
> wrote:
>> Hmmm, see I'm loading the template from a plugin directory, not the
>> database.
>
> In that case, you were probably on the right track originally, but you
> need add the blog context manually:
>
> my $ctx = MT::Template::Context->new();
> $ctx->{__stash}{'blog'} = $blog;
>
> (of course, prior to this you need to load the blog object into $blog)
>
> -Mark
>



#2100 From: "Michael Thomsen" <mikerthomsen@...>
Date: Wed Sep 3, 2008 6:12 pm
Subject: Re: How should I initialize a template context?
codemonkeyov...
Offline Offline
Send Email Send Email
 
Thanks, but that doesn't seem to work with MT::Template->build. I was
logging the output, and each time it kept ignoring the params hash.

On Wed, Sep 3, 2008 at 2:04 PM, jesse <jessedp@...> wrote:
> Michael, you should be able to just shove any other variables you want into
> the $params hash you have setup there.
>
> I'm not real great with my perl and what syntax is equivalent, but what
> works for me is like this:
>
> my $pars = { 'error_msg'=>$error_msg, 'success_msg'=>$success_msg };
> $params->{content}=$my_content;
> $params->{lists} = \@lists;
> my $output = $template->build($ctx, $params);
>
> not certain if:
> $params{content} = $my_content;
>
> is equivalent. I've fudged this a bit b/c I'm actually calling this when I
> build the template (just a slightly different way)
> $app->build_page( $tmpl , $pars );
>
> But I'm pretty sure they build & build_page have the same method signatures.
>
> Also, I included the "lists" param above b/c I am using that in mt:loop and
> it works fine (well, except for the other open question I sent this
> morning).
>
>
> jesse
>
> On Wed, Sep 3, 2008 at 13:54, Michael Thomsen <mikerthomsen@...>
> wrote:
>>
>> Ok, that works. How do I pass it variable values so that tags like
>> <mt:var and <mt:loop can get populated? What I have right now is:
>>
>> $params{items} = \@commentData;
>> $params{commenter_author_name} = $new->author();
>> my @blog = MT::Blog->load({id => $new->blog_id()});
>> my $ctx = MT::Template::Context->new();
>> $ctx->{__stash}{'blog'} = $blog[0];
>> $ctx->{__stash}{commenter_author_name} = $new->author();
>>
>> my $output = $template->build($ctx, \%params);
>>
>> On Wed, Sep 3, 2008 at 1:31 PM, Mark Carey <mtpronet@...> wrote:
>> > On Wed, Sep 3, 2008 at 9:39 AM, Michael Thomsen <mikerthomsen@...>
>> > wrote:
>> >> Hmmm, see I'm loading the template from a plugin directory, not the
>> >> database.
>> >
>> > In that case, you were probably on the right track originally, but you
>> > need add the blog context manually:
>> >
>> > my $ctx = MT::Template::Context->new();
>> > $ctx->{__stash}{'blog'} = $blog;
>> >
>> > (of course, prior to this you need to load the blog object into $blog)
>> >
>> > -Mark
>> >
>
>

#2101 From: "Mark Carey" <mtpronet@...>
Date: Thu Sep 4, 2008 3:22 pm
Subject: Re: How should I initialize a template context?
bsakamano
Offline Offline
Send Email Send Email
 
On Wed, Sep 3, 2008 at 2:54 PM, Michael Thomsen <mikerthomsen@...> wrote:
> Ok, that works. How do I pass it variable values so that tags like
> <mt:var and <mt:loop can get populated? What I have right now is:

While there is likely more than one way, here is one way to populate <mt:var>:

$ctx->var( 'commenter_author_name', $name );

For <mt:loop, it seems like what you are doing should work, but it may
depend on the structure of your array.  Here a simple example
generalized from one of my plugins:

my @objects = $class->load({ foo => 'bar' });
my @data;
foreach my $obj (@objects) {
   my $row = $obj->column_values;
   push @data, $row;
}
$param->{my_items} = \@data;

-Mark

#2102 From: "Michael Thomsen" <mikerthomsen@...>
Date: Thu Sep 4, 2008 3:37 pm
Subject: Re: How should I initialize a template context?
codemonkeyov...
Offline Offline
Send Email Send Email
 
Yeah, that's the gist of what I was doing with the loop variable. It
was just a list with a series of hashes inside of it. Thanks for the
info!

On Thu, Sep 4, 2008 at 11:22 AM, Mark Carey <mtpronet@...> wrote:
> On Wed, Sep 3, 2008 at 2:54 PM, Michael Thomsen <mikerthomsen@...>
> wrote:
>> Ok, that works. How do I pass it variable values so that tags like
>> <mt:var and <mt:loop can get populated? What I have right now is:
>
> While there is likely more than one way, here is one way to populate
> <mt:var>:
>
> $ctx->var( 'commenter_author_name', $name );
>
> For <mt:loop, it seems like what you are doing should work, but it may
> depend on the structure of your array. Here a simple example
> generalized from one of my plugins:
>
> my @objects = $class->load({ foo => 'bar' });
> my @data;
> foreach my $obj (@objects) {
> my $row = $obj->column_values;
> push @data, $row;
> }
> $param->{my_items} = \@data;
>
> -Mark
>

#2103 From: Mikael Sheikh <mikael.sheikh@...>
Date: Wed Sep 17, 2008 10:34 pm
Subject: XML-RPC boolean values
nycmilkshake
Offline Offline
Send Email Send Email
 
Should boolean values in XML-RPC be passed as 'true'/'false', as 1/0,
or are both valid?

I'm using the Photon 1.2 iPhoto plug-in, which is sending the
MT::Placement->is_primary boolean as true/false, which MT's
XMLRPCServer.pm is not translating to 1/0.  Subsequently when
MT::Object's save method is called (inherited by MT::Placement), the
is_primary value of 'true' is not stored in the DB as the boolean
field is a tinyint that is expecting a 1/0 value.

Is Photon at fault for not sending 1/0, or is MT's XMLRPCServer.pm
being incorrectly inflexible?

Many thanks!

Mikael Sheikh

#2104 From: "Michael Thomsen" <mikerthomsen@...>
Date: Wed Oct 8, 2008 8:10 pm
Subject: Proper way to get a thumbnail?
codemonkeyov...
Offline Offline
Send Email Send Email
 
I've been logging the results of $imageAsset->thumbnail_file() and all
I see is a numeric value. What do I need to do get usable path to the
thumbnail file?

#2105 From: Mark Paschal <mark@...>
Date: Thu Oct 9, 2008 6:00 pm
Subject: Re: Proper way to get a thumbnail?
markpaaasc
Offline Offline
Send Email Send Email
 
Michael Thomsen wrote:
> I've been logging the results of $imageAsset->thumbnail_file() and all
> I see is a numeric value. What do I need to do get usable path to the
> thumbnail file?

thumbnail_file() returns multiple values: the URL as well as the width
and height of the image. If you only want the URL, call it like:

      my ($url) = $imageAsset->thumbnail_file();

If you want all three, use:

      my ($url, $width, $height) = $imageAsset->thumbnail_file();

HTH.


Mark Paschal
mark@...

#2106 From: jesse <jessedp@...>
Date: Mon Oct 20, 2008 2:56 pm
Subject: Login for MT Plugin Directory
jessedp23
Offline Offline
Send Email Send Email
 
Can anyone point me towards someone or some process that can reset the login attached to my plugin? Apparently the info I wrote down is incorrect or was changed, and I don't know the secret phrase. I've been trying to get in to update it for several weeks, but the places I've tried asking for help have yielded nothing so far. Here's the plugin:
http://plugins.movabletype.org/mailchimp-signup-form/

If you can, please either send me some info or, if you are some that can help, feel free to contact me here or via the email address attached to that plugin.


many thanks,


Jesse

#2107 From: "Mark Carey" <mtpronet@...>
Date: Mon Oct 20, 2008 8:21 pm
Subject: Re: Login for MT Plugin Directory
bsakamano
Offline Offline
Send Email Send Email
 
There is a problem on the plugin directory right now -- even if you
can login successfully, there is no link to access your previously
submitted plugins for editing.  Hopefully 6A will get that fixed
soon...

-Mark

On Mon, Oct 20, 2008 at 11:56 AM, jesse <jessedp@...> wrote:
> Can anyone point me towards someone or some process that can reset the login
> attached to my plugin? Apparently the info I wrote down is incorrect or was
> changed, and I don't know the secret phrase. I've been trying to get in to
> update it for several weeks, but the places I've tried asking for help have
> yielded nothing so far. Here's the plugin:
> http://plugins.movabletype.org/mailchimp-signup-form/
>
> If you can, please either send me some info or, if you are some that can
> help, feel free to contact me here or via the email address attached to that
> plugin.
>
>
> many thanks,
>
>
> Jesse
>

#2108 From: "Timothy Appnel" <tim@...>
Date: Wed Oct 22, 2008 3:53 pm
Subject: YAML registry of CMS Pre Save Entry
tappnel
Offline Offline
Send Email Send Email
 
I'm trying to registry a couple of callbacks to run when an entry or
page is saved in the CMS. I have this in my config.yaml file.

callbacks:
   WYSITidy_entry:
     callback: MT::App::CMS::cmspresave.entry
     handler: $WYSITidy::MT::Plugin::WYSITidy::pre_save
     priority: 10

Debugging message say it does not run though. MT 4.21 displays it in
the list of plugins so its being recognized and read. What form have
others used?

One thing: I working off of these docs and the names seem off to
me(underscores?)  or perhaps they where changed?

http://www.movabletype.org/documentation/developer/callbacks/

<tim/>

--
Timothy Appnel
Appnel Solutions
http://appnel.com/

#2109 From: "Mark Carey" <mtpronet@...>
Date: Wed Oct 22, 2008 4:12 pm
Subject: Re: YAML registry of CMS Pre Save Entry
bsakamano
Offline Offline
Send Email Send Email
 
I believe underscores is correct, as shown at:

http://www.movabletype.org/documentation/developer/callbacks/mtappcmscms-pre-sav\
etype.html

Just checked one of my plugins, and I have
MT::App::CMS::cms_post_save.entry and it works.

Seems like the TOC page you linked is stripping out the underscores,
whereas if you click through to each, the underscores are shown.
Byrne, it would be good to get that fixed ;)

-Mark


On Wed, Oct 22, 2008 at 12:53 PM, Timothy Appnel <tim@...> wrote:
> I'm trying to registry a couple of callbacks to run when an entry or
> page is saved in the CMS. I have this in my config.yaml file.
>
> callbacks:
>  WYSITidy_entry:
>    callback: MT::App::CMS::cmspresave.entry
>    handler: $WYSITidy::MT::Plugin::WYSITidy::pre_save
>   priority: 10
>
> Debugging message say it does not run though. MT 4.21 displays it in
> the list of plugins so its being recognized and read. What form have
> others used?
>
> One thing: I working off of these docs and the names seem off to
> me(underscores?)  or perhaps they where changed?
>
> http://www.movabletype.org/documentation/developer/callbacks/
>
> <tim/>
>
> --
> Timothy Appnel
> Appnel Solutions
> http://appnel.com/
>
> ------------------------------------
>
> Yahoo! Groups Links
>
>
>
>

#2110 From: "Timothy Appnel" <tim@...>
Date: Wed Oct 22, 2008 4:22 pm
Subject: Re: YAML registry of CMS Pre Save Entry
tappnel
Offline Offline
Send Email Send Email
 
Thanks for the sanity check Mark. Will drop a comment there for Byrne
to pickup. <tim/>

--
Timothy Appnel
Appnel Solutions
http://appnel.com/

#2111 From: "Timothy Appnel" <tim@...>
Date: Thu Dec 18, 2008 6:46 pm
Subject: IE cross-domain cookie domain debugging.
tappnel
Offline Offline
Send Email Send Email
 
Anyone out there have some experience debugging IE cross-domain cookie
domain issue?

I want to hear from you if you do. I have a client whose sign in
facilities stopped working for them when they upgraded to MT 4.21. It
only effects IE 6 & & browsers and the one blog not running under the
same domain name as MT. Contact me directly for more detail. There is
a bounty on this ones head.

Thanks.

<tim/>

--
Timothy Appnel
Appnel Solutions
http://appnel.com/

#2112 From: Andrew famiano <webgroups@...>
Date: Wed Aug 5, 2009 4:21 pm
Subject: adding a class to first entry?
label9ine
Offline Offline
Send Email Send Email
 
How can I add a class to the first entry in a blog?

<mt:If tag="Entries" eq="first entry">
add class
<mt:Else>
do nothing
</mt:if>

Thanks


Messages 2083 - 2112 of 2112   Oldest  |  < Older  |  Newer >  |  Newest
Advanced
Add to My Yahoo!      XML What's This?

Copyright © 2009 Yahoo! Inc. All rights reserved.
Privacy Policy - Terms of Service - Guidelines - Help