This forum has moved to a new location and is in read-only mode. Please visit talk.octobercms.com to access the new location.

romo19554264
romo19554264

Hi, Can you help me to add Component to page, but in the code (dynamic). Here is example:

Set attributes: $attributes['title'] = "Home"; $attributes['url'] = "\";

Create page: $CreatePage = new Page($attributes); $CreatePage->save();

This work perfectly, but now i need to add Compoment for example: $CreatePage->addComponent("Menu");

Thanks for your response.

mjauvin
mjauvin

Based on this trick:

(https://octobertricks.com/tricks/create-cms-page-with-translation-from-php-code)

Try replacing the line assigning a viewBag with this one:

$page->attributes['Menu'] = [];
romo19554264
romo19554264

Thank you very much ! it works perfectly.

1-3 of 3

You cannot edit posts or make replies: the forum has moved to talk.octobercms.com.