Accessing snippet data

18 views
Skip to first unread message

Jonny Gwillim

unread,
Jun 20, 2016, 8:00:45 AM6/20/16
to apostrophenow
We set up a new snippet and populated it.

How do we then access that data on any given page, without associating every snippet with every page?

This is our app.js config:

'glossary': {
 

      extend
: 'apostrophe-snippets',

      name
: 'glossry',

      label
: 'Glossary',

      instance
: 'glossaryTerm',

      instanceLabel
: 'Glossary Term',

      addFields
: [

       
{

          name
: 'title',

          type
: 'string',

          label
: 'Term',

         
def: 'e.g. API'

       
},

       
{

          name
: 'definition',

          label
: 'Definition',

          type
: 'string',

          textarea
: true

       
}

     
],

      removeFields
: [ 'thumbnail', 'hideTitle', 'body'],

      orderFields
: [ 'title', 'definition', 'tags', 'slug', 'published'],

      enableExport
: true

   
}



Cheers!

Tom Boutell

unread,
Jun 20, 2016, 8:59:31 AM6/20/16
to apostr...@googlegroups.com
Hmm. If you want this data on every page, it doesn't sound much like a snippet. You might consider using the apostrophe-preferences module, and using a schema field of type "array". This way it's in req.extras.preferences ("preferences" in nunjucks templates) on any page load.

If you want all of your glossary terms all the time this is more efficient.

--
You received this message because you are subscribed to the Google Groups "apostrophenow" group.
To unsubscribe from this group and stop receiving emails from it, send an email to apostropheno...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.



--


THOMAS BOUTELL, SUPPORT LEAD
P'UNK AVENUE | (215) 755-1330  |  punkave.com
Reply all
Reply to author
Forward
0 new messages