Skip to content
This repository has been archived by the owner on Nov 3, 2023. It is now read-only.

Add hook to FrontendTemplate->getCustomSection() #4944

Closed
fredbliss opened this issue Oct 20, 2012 · 10 comments
Closed

Add hook to FrontendTemplate->getCustomSection() #4944

fredbliss opened this issue Oct 20, 2012 · 10 comments
Labels
Milestone

Comments

@fredbliss
Copy link

I'm finding during template buildouts that this function is more restrictive than it should be to css work. Namely, I can't alter the output/replace it with something that accommodates a class value, for example. Currently this only accepts the ID attribute but at the very least I believe we shouldn't need to use JS to append class(es) to individual section divs.

Thanks, keep up the great work...

@leofeyer
Copy link
Member

Anything else you need besides adding class attributes?

@fredbliss
Copy link
Author

Hi Leo, thanks for responding. No, that's it :)

@leofeyer
Copy link
Member

I'm still trying to figure out whether we need a hook or there is a way to add the CSS classes in the function call (which would be a lot easier than setting up a hook class). Can you please outline the HTML code you want Contao to create to help me decide?

@fredbliss
Copy link
Author

I want to apply a class selector directly to the custom section HTML without JS. This would greatly simplify my job in moving to, for example, the twitter bootstrap responsive framework by following their conventions of using classes across layout elements (e.g. .container and .row class selectors) Contao lets us alter the fe_page template for all other elements except for those custom sections.

If there were a custom section template, or at the very least the raw html for them existed in the fe_page template, that would solve the problem quickly. Since we can include our own frameworks, we should be able to use them fully, rather than nearly rewrite them. :)

Consider the header as the example:

<?php if ($this->header): ?>

<header id="header">
<div class="container">
<?php echo $this->header; ?> 
</div>
<?php endif; ?>

<?php echo $this->getCustomSections('before'); ?>
</header>

and to correct the limitation, change

<?php echo $this->getCustomSections('before'); ?>

to loop through while using the same

<section id="mycustomsection" class="add_my_custom_class_here">...</section>   

elements as you would for any other section.

I can see why this becomes a lot of work for a small bit of change, but it becomes an Achilles heel if I choose to make use of the "use your own css framework" feature that I'm very excited about for Contao 3 :)

You can see why the hook seemed easier in this case, or a template for custom sections... Your thoughts?

@leofeyer
Copy link
Member

Two ideas: either allow to pass a mapper array with CSS class names

<?php echo $this->getCustomSections('before', array('mycustomsection'=>'mycustomclassname')); ?>

or – the better one I think – create a template for custom sections (this was your idea, of course).

@leofeyer
Copy link
Member

The first idea could be added as a "bug fix" to Contao 2.11. The second one would have to be added to Contao 3.

@leofeyer
Copy link
Member

What do you prefer?

@fredbliss
Copy link
Author

Hi Leo,

So sorry I dropped the ball here. I think I'd favor the second idea you mention. Seems like the best solution overall.

@leofeyer
Copy link
Member

Note to myself: also check #2885.

@leofeyer
Copy link
Member

leofeyer commented Apr 4, 2013

I just noticed that if there are custom sections, you can access $this->sections in the template and build any markup around it that you want. Does this solve your problem?

@leofeyer leofeyer closed this as completed Apr 9, 2013
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

2 participants