GithubHelp home page GithubHelp logo

Call sub object of {{ page }} about phile HOT 4 CLOSED

kursusHC avatar kursusHC commented on June 4, 2024
Call sub object of {{ page }}

from phile.

Comments (4)

james2doyle avatar james2doyle commented on June 4, 2024

Here is a way that you can do it just with twig:

{% for page in pages %}
  {# if the myfolder string is in the url then its in content/myfolder #}
  {% if "myfolder" in page.url %}
    <a href="{{ page.url }}">{{ page.title }}</a>
  {% endif %}
{% endfor %}

If that isnt quite what you are looking for, you can write a small PHP script to read all the .md files in the directory. Then use the phileTwigFilters plugin to add that array of files into a twig variable.

You can also use a custom meta, since Phile supports custom meta without any plugins.

{% for page in pages %}
  {# if the myfolder string is in the url then its in content/myfolder #}
  {% if page.meta.folder == "myfolder" %}
    <a href="{{ page.url }}">{{ page.title }}</a>
  {% endif %}
{% endfor %}

Keep in mind that http://mysite.com/myfolder url in Phile actually points to mysite/content/myfolder/index.md. So it shouldn't be a huge hassle to come with with a solution for your problem. The first option I gave is the one that I have used before.

from phile.

kursusHC avatar kursusHC commented on June 4, 2024

Thank you very much for this precise answer, I'm gonna try this, I'm pretty sure it does the trick. Thanks 👍

from phile.

james2doyle avatar james2doyle commented on June 4, 2024

Thanks. The first solution will actually work on Pico as well. Its just some basic Twig code. But I encourage you to give Phile a try. We built it because we were upset at the lack of maintenance and support in Pico.

from phile.

kursusHC avatar kursusHC commented on June 4, 2024

Yep I did, I've switched to Phile for my current project. Custom meta out of the box are awesome ! I did a quick benchmark and indeed Phile is faster. Good to see someone is taking care of the great idea Pico came up with.
And thanks for the nice support !

from phile.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.