Jump to content


  • Posts

  • Joined

  • Last visited

Profile Information

  • Gender
    Not Telling
  • Location
    Brisbane, Australia

Recent Profile Visitors

4,804 profile views

wilsea's Achievements

Full Member

Full Member (4/6)



  1. Thanks LostKobrakai, I was trying to make it work with a Text Field instead of a Page Field. Working like a charm and I love it. Thanks again.
  2. I'm probably overlooking something basic but I can't get this to work. I've located the plugin in the modules directory - installed it on the modules page (no strikeout line any more through Input Chosen Select and Input Chosen Select Multiple). Then when I go to add a new field - but Input Chosen Multiple doesn't appear in the select box for field type. What am I missing? (ProcessWire 2.6.1) - jquery-1.10.2.min.js located in templates>scripts Thanks in advance (feeling very stupid)
  3. Thankyou - working perfectly and solves all my immediate problems.
  4. Thankyou all for the suggestions. Although I've tried changing the setting from $config->timezone = 'Australia/Queensland'; to $config->timezone = 'America/New_York'; it doesn't seem to make any difference - I guess all that is doing is setting the default value for timezone conversions to start from On thinking it over I think I'm going to need to convert the time with a function as suggested by Adrian - I can't be sure that all my users will be in the one timezone so config settings, php.ini and the like won't be appropriate. I've tried Adrian's convert_time_zone function and get an error Failed to parse time string (1405881074) at position 8 (7): Unexpected character ..... and the line number is the first line of the function ie $time_object = new DateTime($date_time, new DateTimeZone($from_tz)); I think maybe DateTime is expecting the $date_time to be in format '2007-11-30 10:30:19' instead of a big number string that comes from $page->created, but that's as far as I've got with trying to the convert_time_zone function working. Need more guru help please.
  5. I'm using $page->created and $page->modified to track the time users start and finish an activity. No problem on localhost, but now that it's on a server there's a 14 hour time difference. I figure there must be a neater fix than adding 14 hours to each record as it is read or created. PW config file already has $config->timezone = 'Australia/Queensland'; I've tried adding date.timezone = "Australia/Queensland" to a php.ini file in a directory above my PW project - no change. Tried adding the same line to PW .htaccess file - and ended up with a 404 until I removed the apparently offending line. Any suggestions anyone?
  6. Thanks arjen - can't believe how long I looked at the code without noticing the missing () . Knew it had to be something obvious but still couldn't see it.
  7. I'm trying to update a number of pages with the following code $levels = $pages->find("template=level"); echo "Changing ". count($levels). " levels"; foreach($levels as $lev){ $lev->setOutputFormatting(false); $lev->user_id = 4233; $lev->save; } The message shows the correct number of levels, so the code is being run, but the pages are not changed. It's probably something trivial, but I can't figure our what I'm missing. Can someone put me on the right track?
  8. I get confused when I look at my code too. I try to keep it clean, but it's easier said than done. The ajax returned result is {gameUrl: "http://localhost:81/processMaths2/games/g_2098_2998_3069/"} , so that's working exactly as it should (once the try catch block was tidied up). It was at the top of my list for likely suspects once you mentioned redirects. The only other redirects are from the logon page, a slightly modified version of an example found on the forum - they work as expected as well. - to teacher admin for user->role = "teacher", to play game for user->role = "student". <?php /* * Basic login * */ function getUserRole($user, $session) { if ($user->hasRole('teacher')) { $teacherPage = wire('pages')->get("template=teacher,user_id=$user->id"); $teacherUrl = $teacherPage->httpUrl; $session->redirect($teacherPage->httpUrl); } if ($user->hasRole("student")) { $student = wire('pages')->get("template=student,user_id=$user->id"); if ($student->game_id == 0) { $game = wire('pages')->get("template=game,name=000"); $gameUrl = $game->url; } else{ $game = wire('pages')->get("template=game,id={$student->game_id}"); $gameUrl = $game->url; } $session->redirect($game->url); } } // check for login before outputting markup if ($input->post->username && $input->post->pass) { $username = $sanitizer->username($input->post->username); $pass = $input->post->pass; try { $user = $session->login($username, $pass); if (isset($user)) { getUserRole($user, $session); } else { echo "No user found with that name and password. Please try again"; } } catch (Exception $e) { echo $e->getMessage(); } } ?> <p><a href="./teacheradmin/create-teacher-account/">Create an account </a></p><br /> <form action='./' method='post'> <p> <label>Username <input type='text' name='username'></label> <label>Password <input type='password' name='pass'></label> </p> <button type='submit'>Login</button> <p><a href='/reset-pass/'>Forgot your password?</a></p> </form> I deleted the page with id=2983 - it didn't make any difference. I was hoping for an enlightening error message. I tried your suggestions of replacing .htaccess, wire directory and index.php. I went back to earlier versions of the program ( replaced site directory with earlier versions) and the problem is still there - but I'm not sure at what stage it stopped working. The really early versions no longer work with the existing database. No custom hooks are running unless they are part of an installed module. Installed modules are Batcher, Selector test and Jquery Data Tables Plugin. I'm pretty confident it's some sort of user error - I just don't know where to look for it, so I'm starting again with a clean copy of PW. Maybe I'll find some code I've forgotten about in the process. Thanks for checking the problem out. I'll post again if something turns up.
  9. Thanks SiNNut - looks like some nice info and checklists in those links. The warning for the rewrite module not being on probably didn't happen because processwire was already setup - I just copied the directories into the newly created www directory, so didn't go through the install checks.
  10. This forum rocks! I've activated the rewrite_module suggested by 3fingers (I didn't know you could link directly to dropbox accounts - neat) and now the site via wamp server works as it used to with the earlier version of wamp - navigating from page to page is fine using localhost:81/ skyscraper as the root in the browser . As far as I'm concerned, I have two solutions for my initial problem - activate the rewrite_module for apache with wamp, or go with the more user friendly uniform server. (Note sure that I'll be able to hit the solved button twice though). A big thankyou to everyone for your help. I'm learning heaps through this forum. At this stage apache is still a big mystery to me - I still haven't got the hang of virtual hosts, on either wamp or UniServer (a joy to use). Since on my machine both wamp and UniServer access data from an independent installation of MySQL (computer a handmedown from another user and in earlier days I couldn't figure out how to turn the automatically starting MySQL server off), I can switch between servers quite easily. So far I've been unable to convince the browser that skyscraper.dev/ , http://www.skyscraper.dev exists , with either wamp or uniform versions of apache. The output of vhosts for (wamp) apache looks OK to me - port:81 namevhost skyscraper.dev alias www.skyscraper.dev wildalias *.skyscraper.dev, - "Include conf/extra/httpd-vhosts.conf" on the http.conf file is uncommented. - name is correctly spelt on etc/hosts file - stopped and restarted the net dnscache through a cmd prompt - for UniServer - copied the appropriate project files to the vHost directed created by uniserver - checked for typos and made sure that server was actually running and online. It's not an important issue for me at present, but anyone can see what I'm missing something obvious I'd appreciate it.
  11. Thanks SiNNut. I've tried this <VirtualHost *:81> DocumentRoot "c:/wamp/www/process_skyscraper" ServerName skyscraper.dev ServerAlias www.skyscraper.dev *.skyscraper.dev <Directory "c:/wamp/www/process_skyscraper"> AllowOverride All Require local </Directory> </VirtualHost> and in etc/hosts skyscraper.dev ::1 skyscraper.dev along with stopping and restarting dnscache, and restarting wamp server. Localhost still works, but can't find skyscraper.dev. Typing skyscraper.dev into the browser kicks off a google search (Chrome) or a 404 in Firefox. Looks like I'm still missing something. I notice the slashes for the directory are in the other direction in your example - am I correct in thinking that is related to the OS of the server?
  12. Now that I have a server (Uniform Server) up and going again (and recovered from PW withdrawal symptoms) ........ I've checked for redirects, and can't find any that look like a problem. I have redirects from my login page based on $user->role - they all work fine. The problem link is on a template game.php, which doesn't have any redirects on it. <?php /* * create initial variables for game - these are passed to html page as json string * * then display a game setup with appropriate values for logged in player * */ $student = $pages->get('template=student,user_id=' . $user->id); $pageInfo = "UserId = $user->id :StudentID = $student->id : UserRole = $user->roles"; $pageInfo.= " :StudentName = $student->title "; $pageInfo.= " :Game =$page->name :template = $page->template "; // create a variable to pass to javascript as json string $data = new stdClass(); $data->user_id = $student->id; $data->user_name = $student->first_name . " " . $student->last_name; if (!empty($student->game_id) || $student->game_id <> 0) { $data->gameId = $student->game_id; // get game details $game = wire("pages")->get($student->game_id); $data->question_list = $game->question_list; $data->list_pos = $game->list_pos; } else { // set a value that triggers generating a new game $data->gameId = 0; $data->level_id = 0; } // add level data if it exists if (strlen($student->sequence) > 1) { $levels = explode(",", $student->sequence); $data->level_id = $levels[0]; $level = $pages->get('template=level,id=' . $levels[0]); foreach ($level->fields as $field) { $data->{$field->name} = $level->get($field->name); } } //----------------------page presentation ------------------------------------------------------ $config->styles->add($config->urls->templates . 'styles/main.css'); //$config->styles->add($config->urls->templates . 'styles/theme.css'); // if current template has it's own custom CSS file, then include it $file = "styles/{$page->template}.css"; if (is_file($config->paths->templates . $file)) $config->styles->add($config->urls->templates . $file); // add our javascripts //$config->scripts->prepend('http://code.jquery.com/jquery-1.10.2.min.js'); $config->scripts->add($config->urls->templates . 'scripts/main.js'); $config->scripts->add($config->urls->templates . 'scripts/mathGame.js'); $config->scripts->prepend($config->urls->templates . 'scripts/jquery-1.10.2.min.js'); // if current template has it's own custom JS file, then include it $file = "scripts/{$page->template}.js"; if (is_file($config->paths->templates . $file)) $config->scripts->add($config->urls->templates . $file); ?> <html> <head> <meta http-equiv="content-type" content="text/html; charset=utf-8" /> <title><?php echo $page->title ?></title> <?php foreach ($config->styles as $url) echo "<link rel='stylesheet' type='text/css' href='$url' />"; foreach ($config->scripts as $url) echo "<script type='text/javascript' src='$url'></script>"; ?> <script> // pass variables from server php to javascript gameId = <?php echo $page->id ?>; loadedGame = <?php echo json_encode($data) . "; \r\n" ?> </script> </head> <body> <div> <?php echo $pageInfo; ?> </div> <div id="debug" >...</div> <div> Welcome <?php echo $user->name, $session->id ?> </div> <div id="topNav"> <?php include ('./includes/topNav.inc'); ?> </div> <!--===============================================================================================================--> <div id="progress"> <img src ="<?php echo $config->urls->templates ?>/styles/images/glassy-smiley-good.png ?>" height ="50" width = "50" /> </div> <!--======================================= MAIN ====================================================================--> <div id="main" > <table><tr> <!--========================================= NUMPAD =====================================================--> <td> <div id="numContainer" class="left"> <div id ="question"></div> <!--<div id="feedbackContainer" > <div id ="feedback"> <img src ="images/glassy-smiley-good.png" height ="30" width = "30"> </div> </div>--> <div id ="answerDisplay"> <div id="answerInner"> <span id="a0" class="ad"></span><span id="a1" class="ad"></span><span class="ad" id='a2' ></span><span class="ad"></span></div> <img id="feedback" src ="<?php echo $config->urls->templates ?>styles/images/glassy-smiley-good.png ?>" height ="30" width = "30"> </div> <div id="roundResult"></div> <div id="numpadContainer"> <span id="anim"></span> <table id ="numpad" border ="1"> <tr><td><button class ="numbtn numpad">7</button></td> <td><button class ="numbtn numpad">8</button></td> <td><button class ="numbtn numpad">9</button></td></tr> <tr><td><button class ="numbtn numpad">4</button></td> <td><button class ="numbtn numpad">5</button></td> <td><button class ="numbtn numpad">6</button></td></tr> <tr><td><button class ="numbtn numpad">1</button></td> <td><button class ="numbtn numpad">2</button></td> <td><button class ="numbtn numpad">3</button></td></tr> <tr><td></td> <td><button class ="numbtn numpad">0</button></td> <td> <img id="eraser" src ="<?php echo $config->urls->templates ?>styles/images/eraser.jpg ?>" height ="80" width = "80"> </td><tr> </table> </div> <button id="start"><img id="eraser" src ="<?php echo $config->urls->templates ?>styles/images/start.jpg ?>" height ="50" width = "200"><br />START</button> </div> </td> <!--========================================= feedback =====================================================--> <td id="display"> Round List Pos:<div id ='roundPos'>List Pos</div><br /> All List Pos:<div id ='allPos'>All Pos</div><br /> <div id="php" ></div> <div id ="announce"><img src ="<?php echo $config->urls->templates ?>styles/images/glassy-smiley-good.png"></div> </td> </tr></table> </div> </body> </html> It does load a game.js file, which does use ajax to determine a window location if a new game is started . The original code just relied on the right url coming back from the server and going to that page with a window.location - I've now added some error catching to trap any problems, but it was actually working OK without the error trapping. $.ajax({ type: "POST", url: "/processMaths2/backend/ajax-game/", data: game, success: function(rtndata) { $('#debug').html(rtndata); try{ result = $.parseJSON(rtndata) window.location.href = result.gameUrl; } else{ alert("Problem with parsing ajax result") } }, error: function(XMLHttpRequest, textStatus, errorThrown) { console.log(textStatus, errorThrown); } }) The student page which is never being reached via the link doesn't have any redirects - it just displays lots of data. When reached from other pages other than via the problem link, there is no problem. <?php $config->styles->add($config->urls->templates . 'skeleton/stylesheets/layout.css'); $config->styles->add($config->urls->templates . 'styles/main.css'); $config->styles->add($config->urls->templates . 'styles/level.css'); $config->styles->add($config->urls->templates . 'styles/theme.css'); // if current template has it's own custom CSS file, then include it $file = "styles/{$page->template}.css"; if (is_file($config->paths->templates . $file)) $config->styles->add($config->urls->templates . $file); // add our javascripts //$config->scripts->prepend('http://code.jquery.com/jquery-1.10.2.min.js'); $config->scripts->add($config->urls->templates . 'scripts/main.js'); $config->scripts->prepend($config->urls->templates . 'scripts/jquery-1.10.2.min.js'); $config->scripts->add($config->urls->templates . 'scripts/jquery.tablesorter.min.js'); // if current template has it's own custom JS file, then include it $file = "scripts/{$page->template}.js"; if (is_file($config->paths->templates . $file)) $config->scripts->add($config->urls->templates . $file); ?> <html> <head> <meta http-equiv="content-type" content="text/html; charset=utf-8" /> <title><?php echo $page->browser->title ?></title> <?php foreach ($config->styles as $url) echo "<link rel='stylesheet' type='text/css' href='$url' />"; foreach ($config->scripts as $url) echo "<script type='text/javascript' src='$url'></script>"; ?> </head> <body> <?php echo $page->friendlyTitle; ?> <?php echo $user->role, $user->name ?> <div id="topNav"> <?php include ('./includes/topNav.inc'); ?> <!-- Top nav bar here--> </div> <div class="tabs"> <ul> <li id="tabHeader_1">Current Game Grid</li> <li id="tabHeader_2">Current Game Table</li> <li id="tabHeader_3">History Grid</li> <li id="tabHeader_4">History Table</li> <li id="tabHeader_5">Charts</li> <li id="tabHeader_6">Summary</li> </ul> </div> <div id="debug">...</div> <div id='tabContent'> <div id='tabContent_1' class="content"> <?php echo $page->get('game_grid') ?></div> <div id='tabContent_2' class="content" > <?php include("includes/s_current_game.inc") ?> </div> <div id='tabContent_3' class="content" > <?php echo $page->get('history_grid') ?> </div> <div id='tabContent_4' class="content" > <?php include("includes/s_history.inc") ?> </div> <div id='tabContent_5' class="content" > <?php echo $page->get('charts') ?></div> <div id='tabContent_6' class="content"> <?php echo $page->get('summary') ?></div> </div> <!-- end tabContent -----> <div id='main'><?php echo $page->get('outMain|body'); // use outMain if there, or body otherwise ?></div> <div id='side'><?php echo $page->get('outSide|sidebar'); // use outSide if there, or sidebar otherwise ?></div> </body> </html> student.php uses student.js to move from tab to tab, and display and sort tables of results. - no window.location anywhere. Obviously the id=2983 must be coming from somewhere, but I can't figure out where.
  13. Just discovered The Uniform Server through a post from SiNNut, and now I'm up and going with it. Completely painless. I'm curious to know if there was a simple fix for wamp, and also what servers people are using though.
  14. @SiNNut The Uniform Server is an absolute gem! Felt like it only took 30 seconds to setup! Very sweet. Now I can get back to programming with processwire! Thanks a million!
  15. I've reinstalled wamp,upgrading from 2.2 to 2.5 in the process, and now I can't get past the home page on any processwire site on localhost - including the basic skyscraper site. That includes getting to the admin site with localhost:81/myprocesswire/processwire. Any page other than the home page returns me to the wampserver home page, with the url of the desired page in the address bar of the browser ie http://localhost:81/process_skyscraper/cities/ displays the wamp home page. Apache is working fine for other sites (eg joomla). The difference seems to be the trailing slash at the end of the url. Some googling came up with WAMPServer 2.5 The Homepage, Your Projects Menu and the need for Virtual Hosts , and I followed the advice on that site to setup a virtual host for a processwire site. It also seems to me to be a relatively complex process - (1) editing httpd-hosts.conf (2) running notepad as administrator to edit C:\windows\system32\drivers\etc\hosts (3) running command prompt as administrator to restart dnscache . It doesn't seem to have made any difference. I tried DocumentRoot with and without the trailing slash in the VirtualHost settings. My virtual host definition looks like this. <VirtualHost *:81> DocumentRoot "c:/wamp/www/process_skyscraper/" ServerName localhost ServerAlias localhost <Directory "c:/wamp/www/process_skyscraper"> AllowOverride All Require local </Directory> </VirtualHost> My gut feeling is that probably none of this is necessary, and I'm looking in the wrong place of a solution. Are all new users of processwire really going through these steps just to get it going? Any thoughts on what I'm missing?
  • Create New...