stacey icon indicating copy to clipboard operation
stacey copied to clipboard

Snippet: Recursive menu in Stacey 3.*

Open mjau-mjau opened this issue 12 years ago • 18 comments

Just wanted to share a snippet for creating a recursive menu in Stacey 3.* with Twig. Simply create a partial template partials/root-menu.html:

{% for child in node|default(page.root) %}
<li{% if child.children_count > 0 %} class=has-dropdown{% endif %}>
  <a href="/{{ child.permalink }}">{{ child.label|default(child.slug|title) }}</a>
  {% if child.children_count > 0 %}
  <ul class=dropdown>
    {% include "partials/root-menu.html" with {'node': child.children} %}
  </ul>
  {% endif %}
</li>
{% endfor %}

In the above, you may need to edit the content of the <a> link. Add it to your main template like this:

<ul class="your-menu-class">
  {% include 'partials/root-menu.html' %}
</ul>

mjau-mjau avatar Dec 30 '13 08:12 mjau-mjau

Nice!

How about a "Stacey snippets" in the Wiki?

o-l-e avatar Jan 02 '14 20:01 o-l-e

Indeed. I was perhaps hoping for a snippets section on a new Stacey website.

mjau-mjau avatar Jan 03 '14 03:01 mjau-mjau

@o-l-e Snippets in the Wiki is an awesome idea. So much so that I thought I'd take a crack at adding it to the Wiki. I used @mjau-mjau 's snippet as the first entry. What do you all think? https://github.com/kolber/stacey/wiki

pbatts avatar Oct 30 '14 12:10 pbatts

@pbatts that's great! I added a snippet in there just now together with @mjau-mjau 's snippet.

Would be nice with a possibility to post new snippet without having to edit the same post though. Is there any way of creating individual posts in snippets? Maybe a list similar to the wiki itself?

o-l-e avatar Oct 30 '14 20:10 o-l-e

@o-l-e I agree, it would be nice to post new snippet without having to edit the same post. I can see where things could get messy.

It would be easy enough to create sub-pages under the 'Snippets' page. But, that will eventually get messy as well. We would end up with numerous snippet page links showing on the Wiki's Home page and in the menu on the right side of all pages.

Perhaps a better approach would be if @kolber could create a new repo strictly for the creation of a snippets wiki. I've thrown something together here to demonstrate how it might be done.

pbatts avatar Oct 31 '14 01:10 pbatts

@o-l-e Btw, love your snippet.

pbatts avatar Oct 31 '14 01:10 pbatts

Thanks @pbatts i use the active-class partial all the time now, it really does work very well. I don't know what the best solution for the snippets page is. It would be really nice to see it come alive though :)

o-l-e avatar Oct 31 '14 07:10 o-l-e

@o-l-e I have emailed @kolber and asked if this is something he would be interested in and if he would consider my above suggestion a viable solution and, if so, to create the snippets repo.

pbatts avatar Oct 31 '14 14:10 pbatts

Great!

o-l-e avatar Oct 31 '14 16:10 o-l-e

Nice to see there are still figures blowing on the embers! Shortly, I have an ajax-based control panel ready to be used with Stacey, and would be cool if anyone wanted to try it ...

mjau-mjau avatar Nov 01 '14 05:11 mjau-mjau

@mjau-mjau i am sure we all would want to hear more about your control panel. I do!

o-l-e avatar Nov 01 '14 12:11 o-l-e

Sure! Same here, I'd be happy to try the panel @mjau-mjau Cheers!

puleddu avatar Nov 01 '14 13:11 puleddu

@mjau-mjau Definitely looking forward to seeing what you've cooked up.

pbatts avatar Nov 01 '14 14:11 pbatts

All, @kolber has created a new repo for a Snippets Wiki. View it here https://github.com/kolber/Stacey-Snippets/wiki Enjoy.

pbatts avatar Nov 10 '14 00:11 pbatts

A quick glance at the Stacey-friendly ajax panel for those who are interested. This is basically a hurried design version 0.0.1, and we have lots of plans for changes. I have disabled write permissions in this folder, so you won't be able to actually make any changes. http://imagevuex.com/demo/x3/panel/ login as admin/admin

Goals For this panel, we basically had a few fundamental goals:

  • Allow the user to add- and manage folders (pages) inside the content structure.
  • Allow the user to easily edit page content files (normally *.yml or *txt file).
  • Allow the user to upload- and manage files in each folder (galleries etc).
  • Allow the user to easily edit settings (if permitted).

DB There is an optional database-login for the panel, which does not affect Stacey in any way, but it allows multiple users, improved user-management, user-permissions and edit-profile. Screens: http://d.pr/i/17iSS http://d.pr/i/Ox96 http://d.pr/i/LDOE

mjau-mjau avatar Nov 10 '14 06:11 mjau-mjau

Thanks @pbatts and @kolber for the wiki! @mjau-mjau the control panel looks incredible!

o-l-e avatar Nov 10 '14 07:11 o-l-e

This looks fantastic!

kariemil avatar Nov 11 '14 15:11 kariemil

@mjau-mjau ajax panel looks awesome.

pbatts avatar Nov 12 '14 21:11 pbatts