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

[NodeBundle] Added 3 new helper methods #590

Merged
merged 1 commit into from
Jul 28, 2015

Conversation

tentwofour
Copy link
Contributor

Q A
Bug fix? no
New feature? yes
BC breaks? no
Deprecations? no
Fixed tickets

Added 3 new helper methods to NodeMenu:

  • getSiblings($node)
  • getNextSibling($node)
  • getPreviousSibling($node)

Useful for things like linear-style nav (in my case, Next Project/Previous Project), while retaining progressive enhancement.

Some simple template logic, once nodemenu is defined:

{% set currentNode = nodemenu.getCurrent() %}
{% set nextSibling = nodemenu.getNextSibling(currentNode.node, false) %}
{% set prevSibling = nodemenu.getPreviousSibling(currentNode.node, false) %}
                    {% if prevSibling %}
                        <a data-pager="prev"
                           href="{{ path('_slug', {'url': prevSibling.nodeTranslation.url }) }}">
                            ({{ prevSibling.nodeTranslation.title }})
                        </a>
                    {% endif %}

                    {% if nextSibling %}
                        <a data-pager="next"
                           href="{{ path('_slug', {'url': nextSibling.nodeTranslation.url }) }}">
                            ({{ nextSibling.nodeTranslation.title }})
                        </a>
                    {% endif %}

 getSiblings($node)
 getNextSibling($node)
 getPreviousSibling($node)
@tentwofour tentwofour changed the title Added 3 new helper methods: [NodeBundle] Added 3 new helper methods Jul 28, 2015
@roderik roderik added this to the 3.2.3 milestone Jul 28, 2015
roderik pushed a commit that referenced this pull request Jul 28, 2015
@roderik roderik merged commit 5bd680d into Kunstmaan:master Jul 28, 2015
@tentwofour tentwofour deleted the feature_node_menu_enhancements branch October 26, 2015 16:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants