Hardcoding Advertisement Block into Page Type

Permalink Browser Info Environment
Hi there, I've actually got what I think should work (have had success embedding blocks before) but it isn't displaying anything. Maybe I'm missing something in my code.
$bt_ads = BlockType::getByHandle('advertisement');
$bt_ads->controller->existing_source = 'group';
$bt_ads->controller->existing_agID = '1';
$bt_ads->controller->numAds = '3';                   
$bt_ads->render('view');

Any pointers?

Type: Discussion
Status: New
fridayphoto
View Replies: View Best Answer
andrew replied on at Permalink Best Answer Reply
andrew
The syntax for this is a little weird. Try something like this:

$bt = BlockType::getByHandle('advertisement');
$bt->controller->numAds = 3;
$bt->controller->agID = 1;
$bt->controller->ad = new AdvertisementDetails();
$bt->controller->ad->aID = 0;
$bt->render('view');

concrete5 Environment Information

Browser User-Agent String

Hide Post Content

This will replace the post content with the message: "Content has been removed by an Administrator"

Hide Content

Request Refund

You have not specified a license for this support ticket. You must have a valid license assigned to a support ticket to request a refund.