Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Alter HTML in Class methods #4

Open
perifer opened this issue Sep 29, 2016 · 6 comments
Open

Alter HTML in Class methods #4

perifer opened this issue Sep 29, 2016 · 6 comments

Comments

@perifer
Copy link
Contributor

perifer commented Sep 29, 2016

Municipio\Helper\Navigation::sidebarMenuAuto() contains HTML that we would like to alter:

        return '<nav id="sidebar-menu">
            <ul class="nav-aside hidden-xs hidden-sm">
                ' . $menu->render(false) . '
            </ul>
        </nav>';

It would be nice if that would be easier to do. Currently the only way to do it seems to be to replace sidebarMenuAuto() with our own function but it contains a lot of other logic which is a shame to duplicate.

@sebastianthulin
Copy link
Member

In what way do you want to change the markup? We could add a filter, but might prefer to improve the markup itself too.

@perifer
Copy link
Contributor Author

perifer commented Sep 29, 2016

In this specific case this is our ideal markup (we are adding a header before the menu, note aria-labelledby="sidebar-menu-headline" which is added to nav):

<h2 id="sidebar-menu-headline" class="sidebar-menu__headline"><span class="visually-hidden">Undernavigation för </span>{{ $ancestor }}</h2>
<nav id="sidebar-menu" aria-labelledby="sidebar-menu-headline">
    <ul class="nav-aside hidden-xs hidden-sm">
        {{ $menu }}
    </ul>
</nav>

The most logical place to change this would to me would be in sidebar-left.blade.php or a new blade partial. I feel that there is more places like this through out Municipio that could benefit from having HTML-code in partials instead of in PHP functions.

@perifer perifer changed the title Alter HTML for sidebar menu Alter HTML in Class methods Sep 30, 2016
@perifer
Copy link
Contributor Author

perifer commented Sep 30, 2016

A new example is in Municipio\Theme\Navigation::addSearchMagnifier() where we would like to remove pricon and alter classes.

@sebastianthulin
Copy link
Member

Please feel free to provide us with solution examples trough a PR. Ideally we should use blade engine in most cases.

@perifer
Copy link
Contributor Author

perifer commented Oct 4, 2016

Cool. I actually looked through some of your source code to see if I could find any examples of Class methods using blade to render HTML, but didn't find anything. I'll see if I can look at this some more.

@sebastianthulin
Copy link
Member

You may do something like this function to fetch a template: https://github.com/helsingborg-stad/Municipio/blob/master/library/Template.php#L98

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants