Open adammahon opened 8 years ago
pages()
returns an array. So I guess pages()[0].get('tmp')
is what you need where 0
is the index of the page.
Thanks for the reply krasimir! I saw that there were no new commit and no new issues submitted for several months so I was worried my post wouldn't be seen.
Yes, the code you gave does work. That being said, I don't see it being useful in that context. To use it as you suggested implies:
pages()[0].get('var_name_here')
and later on created a page that became the new 0th index, you would have to go through every page that is using pages()[0].get('var_name_here')
and change the index to whatever index returns the page you want. This goes back to my point above where it is safer and easier to use multiple page() functions instead of the pages() function.Now all that being said, I reread the documentation and realized I missed this line in the Writing your own functions section:
all the methods which you normally use in the Markdown file are available.
With this, I do see several uses for pages(). In fact, I was able to use it to create a dynamic navigation and being able to use the pages() function saved me quite a bit of time. However in the end, custom functions are the only use I really see for the pages() function. It doesn't seem to play well with the built-in methods.
I see. To be honest I'm not using Techy anymore. And that's not because it's not working or it's not cool. It's because I don't have time to migrate my blog completely. So, I'm not really sure what could be done with pages()
. Probably I had some idea months ago and I decided to implement the method.
I'm a little confused on the usage of the pages() function. I've read the documentation and tried a couple tests, but I can't seem to understand what the use of it is. Unless I'm mistaken, it doesn't appear Techy has any way of accessing the data in the array pages() returns. I know with page(), you can get data from it using the get() function. However with pages(), if you use get(), how will you know what index you are getting data from? Is there some feature I'm missing that would allow me to access the data?
For the project I'm working on, I was hoping I could get the data from pages and loop through it to create a nav menu. Is something like this possible with Techy?
EDIT: after doing a few more tests, it seems get() doesn't work with pages(). Page() works just fine, but pages() errors out.
Here is the code I tested it with:
<% page('Header').get('temp') %> -- Works just fine
<% pages().get('temp') %> -- errors