Login | Register For Free | Help
Search for: (Advanced)

Mailing List Archive: Bricolage: users

copying categories from one story to another

 

 

Bricolage users RSS feed   Index | Next | Previous | View Threaded


acaul at rand

Feb 3, 2009, 10:29 AM

Post #1 of 7 (1550 views)
Permalink
copying categories from one story to another

I am trying to copy categories from one story to another. For each, I
have whittled everything down to an array of categories to add to the
new story. The array is valid and populated. My code looks like this.

$newstory = $newstory->add_categories(@cats);
$newstory->save();


When I run the template, I get this error:

Not an ARRAY reference at /usr/local/bricolage/lib/Bric/Biz/Asset/
Business/Story.pm line 1573, <GEN559> line 222.


I am guess that this means I am passing the categories incorrectly to
the add_categories method. Does anyone have the correct syntax, or is
it something else? Thanks.

P.S. I have also tried
$newstory = $newstory->add_categories({@cats});
but I get the same error.

__________________________________________________________________________

This email message is for the sole use of the intended recipient(s) and
may contain confidential information. Any unauthorized review, use,
disclosure or distribution is prohibited. If you are not the intended
recipient, please contact the sender by reply email and destroy all copies
of the original message.


greg at node79

Feb 3, 2009, 11:40 AM

Post #2 of 7 (1485 views)
Permalink
Re: copying categories from one story to another [In reply to]

Hi Ashlee,

Try passing it in as an array reference:
$newstory->add_categories(\@cats);

The API docs are a little inconsistent (one place says to pass an
array reference, another suggests not) but array reference will always
work. If @cats is made up of category IDs, then either \@cats or @cats
will work; I'm guessing @cats is made up of category *objects* since
you're getting the error.

Best,
-Greg


On 3-Feb-09, at 1:29 PM, Ashlee Caul wrote:

> I am trying to copy categories from one story to another. For each,
> I have whittled everything down to an array of categories to add to
> the new story. The array is valid and populated. My code looks like
> this.
>
> $newstory = $newstory->add_categories(@cats);
> $newstory->save();

---
Greg Heo
web/software systems developer
greg [at] node79
416.826.7630


acaul at rand

Feb 3, 2009, 12:32 PM

Post #3 of 7 (1479 views)
Permalink
Re: copying categories from one story to another [In reply to]

Ah, fantastic! That worked! Thank you so much.

P.S. Yes, it is category objects.

On Feb 3, 2009, at 2:40 PM, Greg Heo wrote:

> Hi Ashlee,
>
> Try passing it in as an array reference:
> $newstory->add_categories(\@cats);
>
> The API docs are a little inconsistent (one place says to pass an
> array reference, another suggests not) but array reference will
> always work. If @cats is made up of category IDs, then either
> \@cats or @cats will work; I'm guessing @cats is made up of
> category *objects* since you're getting the error.
>
> Best,
> -Greg
>
>
> On 3-Feb-09, at 1:29 PM, Ashlee Caul wrote:
>
>> I am trying to copy categories from one story to another. For
>> each, I have whittled everything down to an array of categories to
>> add to the new story. The array is valid and populated. My code
>> looks like this.
>>
>> $newstory = $newstory->add_categories(@cats);
>> $newstory->save();
>
> ---
> Greg Heo
> web/software systems developer
> greg [at] node79
> 416.826.7630
>
>
>


__________________________________________________________________________

This email message is for the sole use of the intended recipient(s) and
may contain confidential information. Any unauthorized review, use,
disclosure or distribution is prohibited. If you are not the intended
recipient, please contact the sender by reply email and destroy all copies
of the original message.


zdravko.balorda at siix

Feb 3, 2009, 11:30 PM

Post #4 of 7 (1464 views)
Permalink
Re: copying categories from one story to another [In reply to]

>>> have whittled everything down to an array of categories to add to the
>>> new story. The array is valid and populated. My code looks like this.
>>>
>>> $newstory = $newstory->add_categories(@cats);
>>> $newstory->save();

I have a question here: what happens if this is done over and over again
each time a template is run?

Regards, Zdravko


david at kineticode

Feb 4, 2009, 9:15 AM

Post #5 of 7 (1455 views)
Permalink
Re: copying categories from one story to another [In reply to]

On Feb 3, 2009, at 11:30 PM, Zdravko Balorda wrote:

>>>> $newstory = $newstory->add_categories(@cats);
>>>> $newstory->save();
>
> I have a question here: what happens if this is done over and over
> again
> each time a template is run?

Life as we know it will end. So, don't do that. ;-)

Best,

David


zdravko.balorda at siix

Feb 4, 2009, 11:27 PM

Post #6 of 7 (1463 views)
Permalink
Re: copying categories from one story to another [In reply to]

David E. Wheeler wrote:
> On Feb 3, 2009, at 11:30 PM, Zdravko Balorda wrote:
>
>>>>> $newstory = $newstory->add_categories(@cats);
>>>>> $newstory->save();
>>
>> I have a question here: what happens if this is done over and over again
>> each time a template is run?
>
> Life as we know it will end. So, don't do that. ;-)

Indeed, David. :)

I wonder if this kind of story processing should be done outside the
templates. Perhaps by SOAP?

Zdravko


acaul at rand

Feb 5, 2009, 7:33 AM

Post #7 of 7 (1460 views)
Permalink
Re: copying categories from one story to another [In reply to]

>>>>>> $newstory = $newstory->add_categories(@cats);
>>>>>> $newstory->save();
>>>
>>> I have a question here: what happens if this is done over and
>>> over again
>>> each time a template is run?
>> Life as we know it will end. So, don't do that. ;-)
>
> Indeed, David. :)
>
> I wonder if this kind of story processing should be done outside
> the templates. Perhaps by SOAP?

Normally I would do something like this via SOAP and a fancy Perl
XMLTwig script, but I am only going to do it once to about 250
stories. It seemed like a waste of time to do more than use a template.


__________________________________________________________________________

This email message is for the sole use of the intended recipient(s) and
may contain confidential information. Any unauthorized review, use,
disclosure or distribution is prohibited. If you are not the intended
recipient, please contact the sender by reply email and destroy all copies
of the original message.

Bricolage users RSS feed   Index | Next | Previous | View Threaded
 
 


Interested in having your list archived? Contact Gossamer Threads
 
  Web Applications & Managed Hosting Powered by Gossamer Threads Inc.