How to use a "global" field type ?
Created 6 years ago by tghpow

Hi, I have a slider of images on many pages. Is there a way to to create a "global" field type of files ? Like this, i can manage my pictures and use this field type on some pages. Pictures we'll be the same at every pages. Thanks. EDIT: Sorry, i just see "variables" module... My fault

cleancookie  —  6 years ago Best Answer

If you don't already have anything implemented, you could give the Variables Module a try: https://pyrocms.com/documentation/variables-module/latest

You make a field (image or file field in this case) and then make a group, and assign that field to the group. Then in Variables you upload your image. You should be able to then output that image in any twig file.

piterden  —  6 years ago

What migrations do you have now? Or you created FT with Control Panel?

tghpow  —  6 years ago

Thanks for your answer. I have the last Pyrocms. Yes i create FT with Control Panel. But i just see that maybe i can use "variable module" no ?

cleancookie  —  6 years ago Best Answer

If you don't already have anything implemented, you could give the Variables Module a try: https://pyrocms.com/documentation/variables-module/latest

You make a field (image or file field in this case) and then make a group, and assign that field to the group. Then in Variables you upload your image. You should be able to then output that image in any twig file.

tghpow  —  6 years ago

Yes thanks, it's work fine. Thanks all for helping.

tghpow  —  6 years ago

So i create a group => theme_variables and a field => slider_top.

When a try a dd in my template like that: {{ dd(variable('theme_variables', 'slider_top' )) }}

I have this error: "An exception has been thrown during the rendering of a template ("SQLSTATE[42S02]: Base table or view not found: 1146 Table 'agrisymbiose.agrisymbiose_variables ▶"

Agrisymbiose is the name of my theme.

I have this table in my bdd: agrisymbiose_variables_theme_variable and agrisymbiose_variables_slider_top. But effectivly, i havent the table 'agrisymbiose.agrisymbiose_variables'. Did i miss something ?

ryanthompson  —  6 years ago

@tghpow make sure you've got your variable group slug and field slug correct perhaps? If the forms in the CP work correctly then they're good to go. Not sure why it'd be looking for a different table unless something was missing/typo in slugs.

tghpow  —  6 years ago

@ryanthompson I think i know why: I changed the group name / slug after i had assigned a field type. Maybe it's the cause of this bug ? I deleted my group and my field type and i created them again (different name/slug) and now it's work fine.