Jump to content

Search the Community

Showing results for tags 'variable'.

  • 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

Product Groups

  • Form Builder
  • ProFields
  • ProCache
  • ProMailer
  • Login Register Pro
  • ProDrafts
  • ListerPro
  • ProDevTools
  • Likes
  • Custom Development

Find results in...

Find results that contain...


Date Created

  • Start

    End


Last Updated

  • Start

    End


Filter by number of...

Joined

  • Start

    End


Group


AIM


MSN


Website URL


ICQ


Yahoo


Jabber


Skype


Location


Interests

Found 6 results

  1. anyone, any ideas how to solve? i get following error on a website: Notice: Undefined variable: out in /var/sites/i/islandmemorials.co.uk/public_html/site/templates/includes/functions.php on line 43 and this is a code in that very functions file: <?php function numberOpen() { date_default_timezone_set("Europe/London"); $currentHour = date('G'); if($currentHour > 9 && $currentHour < 21) { $openFor = 21 - $currentHour; if($openFor > 1) { echo "We're currently open for another ".$openFor." hours, why not pop in?"; } else { echo "Our lines are open for another hour - <a href=\"tel:+01983 857 600\">01983 857 600</a>"; } } else { echo "Unfortunately, our lines are currently closed, but you can still send a message below"; } } function getSubNav($pid) { $test = wire('pages')->get("/services/"); $parents = wire('page')->parentID; $template = wire('page')->template; $out = ''; //echo "pid".$pid."<BR>"; //echo "parents".$parents."<BR>"; //echo "template".$template."<BR>"; $children = $test->children; foreach($children as $child) { $class = $child->id === $pid ? " active" : 'inactive'; if ($child->id === $pid ) { $class= 'active'; } elseif ($template= "memorials" && $child->id === $parents ) { $class= 'active'; } $out .= "<li><a class='{$class}' href='{$child->url}'>{$child->title}</a></li>"; } return $out; } ?> i suppose this has to do with a variable scope, but not sure
  2. I'm a beginner and was wondering why the code below isn't working. The issue is where ARTIST (capitalised) appears in the code for the second time. I want it to take the value from the first mention of ARTIST, but it's not doing anything. If I replace the second instance with the name of an artist, then it displays as expected. Hopefully I'm making a basic error! <!--Show artists that are related to current exhibition--> {% set ARTIST = page.exhibition_artist %} {% for artist in artist %} {{ artist.title }} <!--Show works that are related to current exhibition and belong to a given artist--> {% set work = pages.find("template=work, work_exhibition=[page.path], work_artist=[ARTIST]") %} {% for work in work %} {{ work.title }} {% endfor %} {% endfor %}
  3. Hi all, Currently I am working on a filter for all the products in a category. So I've set up a class and built a (PW) form in it. When the user clicks on continue the form should return a processform function which sets the variable of the form in a session. Later in the file I want to read out that session and use that variable to select which products should show up and which should be hidden. So now with code examples to make it a bit more clear for you: In my file I start with a class: class classname { public function ShowForm() { $form = $this->Form1(); if ($this->input->post->submit) { if ($this->processForm1($form)) $this->session->redirect("./"); } return $form->render(); } Then a form inside the class: protected function Form1() { $form = wire('modules')->get("InputfieldForm"); $form->description = "Fill in the fields to find the mouse which fits your wishes"; $form->label = "Mouse Selector"; $form->action = "./"; $form->method = 'post'; $f = wire('modules')->get("InputfieldRadios"); $f->name = "Hand"; $f->label = "label"; $f->addOption(1, "1"); $f->addOption(2, "2"); $form->add($f); $this->addSubmit($form, 'Continue'); return $form; } This function is called when the user submits: protected function ProcessForm1($form) { $form->processInput($this->input->post); $this->session->hand = (int)$form->get("Hand")->value; } As you see I store the variable of the submitted form in a session. After closing the class I continue with building the page and then I want to read out that variable: $value = $this->session->hand; $content .= "Value of 'Hand': " . $value; But when I execute this on my website I cannot see the value of the form. Have I done something wrong or how can I fix this? Thanks in advance, ~Harmen
  4. I extended my users-template with a lot af fields? One of them is 'instrument' The code beyond is working fine (see screenshot 1). 'instrument' is a page-select-field in the user template (the pages are violin, cello, clarinet, ...). But this is not nice and efficient coding!! // Violin $person = $users->find('instrument=violin'); echo "violin"; foreach ($person as $p) { // $user fields are shown echo $p->first_name; } // cello $person = $users->find('instrument=cello'); echo "cello"; foreach ($person as $p) { // $user fields are shown echo $p->first_name; } // clarinet $person = $users->find('instrument=clarinet'); echo "clarinet"; foreach ($person as $p) { // $user fields are shown echo $p->first_name; } // and so on With a foreach the code could me more efficient, but the find-selector givns a problem with the variable $instr. // all instrument in a foreach foreach ($user->instrument as $instr){ $person = $users->find('instrument=$instr'); // does not work, neither do find('$instr') and find($instr) echo $instr->title; foreach ($person as $p) { // $user fields are shown echo $p->first_name; } } With $person = $users-find($instr); only the value of $instr is shown (e.g. violin) but not the values of $p (e.g. first name of person. (see screenshot 2) How can I use a variable as find-selector?
  5. I’m trying to use the $template->name by declaring this in "_init.php": $cssFile = $template->name . ".css"; … and I then have this in "_main.php": // Use custom CSS-file if that file exists. <?php if(is_file($config->paths->templates . "styles/$cssFile")) { echo "<link rel='stylesheet' type='text/css' href='{$config->urls->templates}styles/$cssFile' />"; }; ?> However PW throws this notice: Notice: Undefined variable: template in /Users/claus/Sites/ProcessWire/site/templates/_init.php on line 29 Notice: Trying to get property of non-object in /Users/claus/Sites/ProcessWire/site/templates/_init.php on line 29 // Use custom CSS-file if that file exists. Do I have to define $template->name? I thought that was a built-in function?
  6. In the API section of PW website I found a comment made by Apeisa. He wrote: // If the page is editable, then output a link that takes us straight to the page edit screen: if($page->editable()) { echo "Edit"; } I'd like to use this function but the code shown above won't print a link - just a static string. How to edit this so the output would be a link leading to the exact page edit screen in admin control panel? Thanks. PS. Link to the page where I found the comment: http://processwire.com/api/variables/page/
×
×
  • Create New...