<?php
class MyModule extends \Module {
protected function compile() {
$page_alias = 'my-page-alias';
$arrPage = \PageModel::findPublishedByIdOrAlias($page_alias)->current()->row();
$strUrl = $this->generateFrontendUrl($arrPage, '/additionalquerystring/vars');
$this->redirect($strUrl);
}
}
Showing posts with label contao3. Show all posts
Showing posts with label contao3. Show all posts
Sunday, April 7, 2013
Contao 3 – redirect to a frontend url from page alias
Friday, April 5, 2013
Contao 3 – Generate a form inside a custom template
<?php
/**
* STEP #1 (just in case you want to get the form by its alias)
* get the form id from its alias
* if you have the form id you can skip to step #2
*/
$objModel = \FormModel::findByAlias($form_alias);
$form_id = $objModel->id;
/**
* STEP #2
* generate the configuration object
**/
$objContent = new stdClass();
$objContent->form = $form_id;
/**
* STEP #3
* generate the form object
**/
$objForm = new \Form($objContent);
?>
<?php
/**
* STEP #4
* display the Form
**/
?>
<?php echo $objForm->generate(); ?>
Saturday, February 2, 2013
How to manually update newsletter member’s field in Contao 3
// id of the member we wish to update
$memberId = 2;
// array of newsletter channel's id
$arrNewsletter = array("1");
$objMember = \MemberModel::findByPk($memberId);
// first sync the newsletter
$objNewsletter = new \Newsletter();
$objNewsletter->synchronize($arrNewsletter, $objMember)
// after syncing update the member model
$objMember->newsletter = $arrNewsletter;
$objMember->save();
Subscribe to:
Posts (Atom)