Jump to content

Recommended Posts

Hi again, I have another dummy question about Select field use.

I made the field "boardbasis" with select options:




In template I use $page->boardbasis to extract result from "boardbasis" Select field.

As a result I get on page "1 or 2 or 3" (just pointed numbers).

What should I do achieve as a result "Breakfast or Catered"?

Thanks a lot for your assistant.

Have a great weekend,


Share this post

Link to post
Share on other sites

Try $page->boardbasis->name or $page->boardbasis->title if only one selection can be made at time. If multiple pages can be selected, you'll have to foreach through $page->boardbasis (which'll be PageArray in that case) or do something like $page->boardbasis->eq(0)->title.

When echoing out $page->boardbasis, selected page is returned and rendered as numeric ID.

Share this post

Link to post
Share on other sites

When echoing out $page->boardbasis, selected page is returned and rendered as numeric ID.

<quick tut>

And in case you are wondering why this is so...it is no mystery. Look under the hood in your PW database. Select one of your Page Reference Fields db tables (e.g. field_boardbasis). You will see the data stored there is/are the page(s) id(s) of the currently selected page(s) - see attached screenshot. And in case anyone else is still wondering why the ID? Well, with the ID, you can get all sorts of information about a page since the ID is unique - unlike custom fields like title :)

</quick tut>


Share this post

Link to post
Share on other sites

Thanks, Teppo. I trying all variants with ->name,->title but nothing works in my case. And what the difference between only one selection and multiple pages? Where I can check this option?

Share this post

Link to post
Share on other sites

When you create the field, you have radio buttons to choose whether it is a Single Page or a Multiple Page field. When editing the field, this is under BASICS. Also, check under  INPUT when editing the field, scroll down to input field type*. Make sure to make a selection that matches Single Page if your field is for single pages or Multiple Page if it is for multiple pages.Otherwise, you will get no output if you select the wrong type.

Edit: I think some people live right here in these forums ;) Late again!

Edited by kongondo

Share this post

Link to post
Share on other sites

This method is different from what we normally use for select options. As you can guess from the responses, we use page fields to build selects and the options are  actual pages. http://processwire.com/videos/page-fieldtype/ This allows for much more flexible and dynamic building as the options are coming from pages.

The select field you're using is completely different as you have options hardcoded into the field, you could just hardcode the labels in your template too. You know which key has which value. Or to make things simpler you could use the inputfield interface of the select field to get the options..

$options = $fields->selectfieldname->getInputfield($page)->getOptions();
echo $options[$page->selectfieldname];
  • Like 2

Share this post

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Recently Browsing   0 members

    No registered users viewing this page.

  • Similar Content

    • By Neue Rituale
    • By jploch
      Fieldtype Page Table Grid
      This is a sneak preview of a side project I've been working on for quite some time now. A lot of work and thought has gone into this, so I will most likely release this as a commercial module at some point in the near future. 

      As a designer (and developer) I get the appeal of a WYSIWYG editor. After playing around with some WYSIWYG page builder tools, I always felt something was wrong about them. So I decided to build my own PW version based on PageTable.

      Here is a small demo (using AdminThemeCanvas, but its working with other admin themes as well) :
      There is also a complete website that I built for a friend of mine using this module and some custom blocks.
      This fieldtype shares a lot of features with PageTableExtended: it's also an extension of PageTable and renders the block templates in the backend and frontend (native PW templates and fields). You can also add your own css via module settings.
      The difference is, this fieldtype also gives you the ability to rearrange and resize elements in a visual way as well as enable inline editing for text, ckeditor and file fields. Similar (and promising) attempts have been made, but I wanted something based on native CSS grid instead of a CSS framework...so I built my own version. Most CSS frameworks are based on flexbox, which is great for layouting elements horizontally. With CSS grid, you can place elements horizontally and vertically, allowing for layouts that were not previously possible with CSS. Similar to webflow, this fieldtype uses javascript (in the backend) to let you manipulate CSS grid in a visual way to design fully responsive websites (or parts of them). It should still be possible to include a CSS framework if you like (just add the classes to your block markup and include the CSS via module settings).
      The CSS grid layout manipulations are saved in a single field as a JSON array and used to generate a dynamic stylesheet that you simply include in your main template (no inline styles). The styles are saved within the breakpoint you select and cascade down to smaller breakpoints. That means you can specify just the basic breakpoint and adjust other breakpoints if needed. The exception is the mobile breakpoint which will display everything in one column as a default (you can change the layout here too).
      The fieldtype also comes with an optional style panel to manipulate some additional CSS properties directly on the page. You can customize the panel or disable it completely from the module settings (and just use a CSS file that you include via module settings). The style panel is based on inputfields (nothing is saved to the database). This means that you just have to install the module and all fields are available to all blocks automatically (this can be customized). It also has the benefit that your installation is not flooded with fields; this module only installs one field.
      Don't want to give your customer all that power? Design features can be disabled for certain roles. The grid editor role can just edit the content and use the inline editing feature to edit content quickly. You can then also grant access individually to the style panel, resize or drag functionality.
      Blocks are just pages Blocks are defined by native PW templates and fields Manipulate CSS grid in a visual way to design fully responsive websites (or parts of them) Design features can be disabled for certain roles Inline editing of text, ckeditor and file fields The layout is 100% CSS grid (very small css file size) Simply drag and resize to manipulate grid items directly inside the backend Manipulate grid columns and rows directly on the page (use any number of columns you want) All style manipulations are saved as JSON and used to generate a dynamic stylesheet that you just include in your main template (no inline styles) Nested groups/grids (child pages of nested blocks are created under group parent) Global blocks work with page reference field (changes on one page, changes all blocks on all pages) Manual and auto placement of grid items Define custom icons for your blocks via native template settings (template -> advanced -> icon) Option to load lazysizes in the backend to enable lazy loading of assets with class lazyload Works with all default and ui-kit based admin themes If you have any questions or feedback, let me know.
    • By franciccio-ITALIANO
      Hi everyone.
      I've created 12 templates that are the same but each with an extra bit of html code. 
      The piece of code is as follows:
      <div> <div class="box-pf"> <i class="fa fa-map-pin fa-2x fa-red faa-pulse animated"></i> <a href=""> <span class="uk-text-middle"><i>Sonchus oleraceus</i> 'Grespino degli Orti'</span></b> </a> </div> </div> On the third line we read "fa-red."
      I created 12 similar templates.
      The first template has only one box with fa-red, the last template has 12 boxes with icons of 12 different colors.
      So. is there any way to have only 1 template and add, if I want and when I want, a small or big, same or different piece of html code?
    • By picarica
      so i made some options in t he field type, and i want to check if selected title is that output this is my sample code
      if($media->r_soc == 'facebook') { $soc = 'facebook'; } elseif($media->r_soc == 'twitter') { $soc = 'twitter'; } i just basically want to check if the user in CMS selected option facebokk and then outpit it into variable which is later outputted into fa icon, oh and also this is all in repeat field
      foreach($ikonky as $media) { so thats why its $media, but as of now it outputs blank state, not sure why,
      it doesnt outpit anything none of the check goes throught these are options i have in the field
      1=facebook 2=twitter 3=instagram 4=youtube 5=github 6=linkedin  
    • By xportde
      How does one enable executables to be uploaded to the File field? Just adding the file extension to the accepted extensions does not seem to work.

      screenshot attached (ignore the label 'video')

  • Create New...