I have a parent page and subpage. The subpage inherit the template from its parent.
Ecole
_ Teachers
__ teacher
__ teacher
For the teacher pages, I added 3 template variables (picture, phone and e-mail)
But the TV is available for the Ecole and teachers resource and I would like to have them only for the teacher resources
Is it possible and how to have the TV available only for the teacher resource without creating a template specialy for the reacher resources?
You should be able to hide them by using a different template for the ecole and teachers pages. It can be an exact duplicate for the one for the teacher pages (or not). Just don’t connect the TVs to the template(s) of the pages where you don’t want them to appear.
As the [[if] concern my profile page, I could remove it, and include in my profile template.
Would it possible to do that, so how
<main>
[[!If?
&subject=`[[*parent]]`
&operator=`inarray`
&operand=`33,32`
&then=` INCLUDE HERE THE PROFILE TEMPLATE`
&else=`[[*content]]`
]]
</main>
In that case, I will have to create a new template, but all my sub resource will ingerit the template of the parent. It’s a point important, because while the use will create a new profile, he/she will not need to have an attention to choose the correct template and then avoid errors,
Hello @bobray
yes, but I can not assign a TV to a chunck, isn’t?
The goal is to assign a TV only for the profile page.
The idea is to include the profile template to the school template only for some subresources (which are the profiles)
I really would avoid conditionals like that and just use two different templates.
You could have a plugin, which would set the right template, while creating new resources.
If you don’t want duplicate your template code, you can put the whole template code into a chunk and call that chunk in your template.
Maybe you could use the extra Collections for this.
If you make the resource “Teachers” a collection, you can specify the default template for all newly created child resources.
An alternative would be a plugin attached to OnDocFormSave that automatically sets the template for the teacher pages:
/* TeacherTemplate plugin */
$teachersId = 12; /* Change to ID of the Teachers page*/
$desiredTemplate = 22; /* change to ID of the Template you want for teacher pages. */
/* Only execute for new resources */
if ($mode !== modSystemEvent::MODE_NEW) {
return "";
}
$parent = (int) $resource->get('parent');
if ($parent !== $teachersId) {
return ""; /* (not a teacher resource) */
} else { /* Set desired template */
if ($resource->get('template') != $desiredTemplate) {
$resource->set('template', $desiredTemplate);
}
}
Hello all
Thanks a lot for all of your replies. I have not had time to read but I will continue my work tomorrow, but I would like to thanks before tomrrow. All look veey interesting. Look forward tomorrow. Thanks
Hello
I just send you a feedback. I have not forgotten to reply to your suggestion but I have to complete the forms of my MODx asap. When I will complete it, I will be back to work around that topic. Sorry for my delay