Search the Community

Showing results for tags 'arrays'.



More search options

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


Forums

  • Welcome to ProcessWire
    • News & Announcements
    • Showcase
    • Wishlist & Roadmap
  • Community Support
    • Getting Started
    • Tutorials
    • FAQs
    • General Support
    • API & Templates
    • Modules/Plugins
    • Themes and Profiles
    • Multi-Language Support
    • Security
    • Jobs
  • Off Topic
    • Pub
    • Dev Talk

Found 4 results

  1. Hi, I'm using this piece of code to retrieve the names of two arrays of images and it works really well. But my question is how can I use only one foreach so i can use both arrays inside of it? Thanks very much. $precioschico = $page->get("planos"); $preciosgrande = $page->get("mapas"); foreach( $preciosgrande as $preciogrande ) { echo $preciogrande . '<br/>'; } foreach( $precioschico as $preciochico ) { echo $preciochico . '<br/>'; }
  2. $stats = array( "total" => array( "main" => array( "selector" => "template=50, parent=$formSuperSelector", "count" => $this->pages->find($stats['total']['main']['selector'])->count ), "yes" => array( "selector" => $stats['total']['main']['selector'].", teilnahme=yes", "count" => $this->pages->find($stats['total']['yes']['selector'])->count ), "no" => array( "selector" => $stats['total']['main']['selector'].", teilnahme=no", "count" => $this->pages->find($stats['total']['no']['selector'])->count ) ), "intern" => array( "main" => array( "selector" => "template=50, formtype=intern, parent=$formSuperSelector", "count" => $this->pages->find($stats['intern']['main']['selector'])->count ), "yes" => array( "selector" => $stats['intern']['main']['selector'].", teilnahme=yes", "count" => $this->pages->find($stats['intern']['yes']['selector'])->count ), "no" => array( "selector" => $stats['intern']['main']['selector'].", teilnahme=no", "count" => $this->pages->find($stats['intern']['no']['selector'])->count ) ), "extern" => array( "main" => array( "selector" => "template=50, formtype=extern, parent=$formSuperSelector", "count" => $this->pages->find($stats['extern']['main']['selector'])->count ), "yes" => array( "selector" => $stats['extern']['main']['selector'].", teilnahme=yes", "count" => $this->pages->find($stats['extern']['yes']['selector'])->count ), "no" => array( "selector" => $stats['extern']['main']['selector'].", teilnahme=no", "count" => $this->pages->find($stats['extern']['no']['selector'])->count ) ), ); var_dump($stats['total']['main']['count']); How can I bring this to work? I always get a "Notice: Undefined variable: stats in..." when trying to access: "count" => $this->pages->find($stats['intern']['yes']['selector'])->count or "selector" => $stats['intern']['main']['selector'].", teilnahme=yes",
  3. Needed to show someone how to quickly setup some settings for various things in a simple text area: could be used for slider settings, site settings, etc; What it does: gives you a matching variable for each key of each line... 1.) setup a textarea field for the settings ; i'm calling it settings_ta 2.) add delimited settings, 1 per line; i use a pipe (|) delimiter; example: address|some info here facebook|https://www.facebook.com twitter|https://twitter.com phone|(999) 999-9999 3.) in your _init.php, get the settings - replace the page number and the name of your settings field: $settings_ta = $pages->get(1644)->settings_ta; $settings_lines = explode(PHP_EOL, $settings_ta); foreach($settings_lines as $settings_row) { $settings_pair = explode('|', $settings_row); ${trim($settings_pair[0])} = trim($settings_pair[1]); } more condensed version, for those of you who like brevity... foreach(explode(PHP_EOL, $pages->get(1644)->settings_ta) as $settings_row) { $settings_pair = explode('|', $settings_row); ${trim($settings_pair[0])} = trim($settings_pair[1]); } now you can do this in your templates: echo $address; echo $facebook; echo $twitter; echo $phone; Edit: made the code simpler....; 2nd edit - added trim to support using ace editor with tabs Addendum: as an added convenience, you could use the Ace text editor module which would give you a monospaced text field and the ability to use tabs for your settings, which could be more readable and easier to edit. The code has been updated to support this by trimming the exploded strings prior to generating the variable/value. address | some info here facebook | http://www.facebook.com twitter | http://twitter.com phone | (999) 999-9999
  4. Hello ppl I'm trying to create an image banner to show in all pages of the site, and for this i created a page to hold multiple images in a field (latter im gonna deal with animating them). The page is published, So this is the tree of values i got: i can address the page with $pg_settings = $pages->get('name=settings'); it seem to be correct because print_r gets me a biiiig array if info now the problem is getting the array of images, with their respective url's. I tried: $pg_settings = $pages->get('name=settings'); // echo "<br />pg_settings: " . print_r($pg_settings->get("banners_slideshow")); // seems ok... $imgs = $pg_settings->get("banners_slideshow"); print_r($imgs[0]->get("url")); // i got nothing?? In this page i also have a non repeatable image field for the logo, so i think i cant use the images array from that page. the question remains: how do i address a field with multiples images, that is in another page? thanks for the patience!