kolber / stacey

Cheap & easy content management
http://staceyapp.com
MIT License
1.04k stars 131 forks source link

Hiding a Page #62

Closed seep closed 11 years ago

seep commented 12 years ago

Is there a way to hide a page so that it is only accessible through Twig collections, and not by URL? Basically, the inverse of omitting a number from the front of the folder (accessible through URL but not Twig). I would like to utilize the directory structure to organize a large collection of items, but only want to present them as a category, not individually.

kolber commented 12 years ago

Could you use YAML sequence to do this?

seep commented 12 years ago

It looks like YAML sequence would provide the data, but I wouldn't be able to use the directory structure if I understand it right. For example, what if each item in the collection had several associated images?

1.category
    1.item-1
        item.yml
        thumb.png
        image_1.png
        image_2.png
    2.item-2
        ...
    3.item-3
        ...
    category.yml

The page for http://example.com/category/ would be

...
{% for child in page.children %}
    <article>
        {{ child.title }}
        {{ child.thumb }}
        {% for image in child.images %}
            <img src="{{ image.url }}">
        {% endfor %}
    </article>
{% endfor %}
...

From here, I would want http://example.com/category/ to be accessible, but I would want http://example.com/category/item-1 or http://example.com/category/item-2 to 404. Is there an existing way to do this within the framework? I'm thinking, some kind of variable in the YML like public? Thanks for your help!

kolber commented 12 years ago

Ah. I see what you're saying here. Well, there probably isn't a simple way to do it with Stacey's built in capabilities. Perhaps something like this could be achieved with some customisation of your .htaccess file?

nchpmn commented 12 years ago

EDIT: Just read the question properly, ignore me :)


Try doing renaming the page you want to be "invisible" so it doesn't have a number at the start.

So from this directory:

1.pages
  1.hello-world
  2.doctor-who
  3.serenity
  4.github

becomes

1.pages
  1.hello-world
  2.doctor-who
  3.serenity
  github

From my understanding, this would remove the page from listings, $children, etc. It does, however, keep the page live for those that know the URL.

Caveat: I'm unsure what happens once you have

1.pages
  1.hello-world
  2.doctor-who
  3.serenity
  github
  5.galactica