Jump to content

Soma

Moderators
  • Posts

    6,798
  • Joined

  • Last visited

  • Days Won

    158

Everything posted by Soma

  1. Thanks interrobang. There's even more possibilities, but depends what AS version is used I did not make any assumptions to what would be appropriate in his situation as I don't know what flash AS version he uses. getURL will work with any actionscript version and was the simplest example to bring the concept in.
  2. Thanks Ryan for the suggestion, I also thought about something like this, but it doesn't work as simple as this, turning off while process is "ProcessPageEditLink". The problem is the page tree select in the link edit dialog which is implement through various jsscripts/php gates... The solution I found works well, and has the nice effect that it shows the page titles in the page list select in the language of the textfield you're making the link. Though requires some modules in the core to be changed.
  3. Referencing to this. I got through it and had to implement the language id of the tinymce field in about 5 core modules to get it to work. So it does, in the link dialog of tinymce, check if it is a language text field and give the language id through various js's,php's ... so if you add a link to a "german" tinymce language field the page list select is in german and returns the german url, and so on. Edit: Of course this all isn't possible through a module or hooks at all.
  4. Next issue is also with setting links in tinymce. They will be inserted in the language the user has in PW admin. You would have to switch between languages in the admin to set them correctly for each language. That again shows, that unfortunately this module/approach is still only a "hack" with lots of drawbacks, and mixes things up that shouldn't. So it still is not the first/best option for creating multilanguage sites imho. That's why I would have prefered a core solution to frontend multilang. But since Ryan isn't in for it, it would be much better to work on the multitree approach and make it more friendly to use in the admin.
  5. I found an issue with textarea fields if "Page Link Abstractor" module by Ryan is used to: "Convert root URLs and page URLs: Prevents broken links when linked pages are moved" ... as soon as I have an image or link in the text, it's not possible to open the page anymore. Looks like that feature can't be used with this module. Haven't looked into it further, but I think since we overwrite path/url the abstractor module hangs itself up. Not sure if there's a solution.
  6. That depends how you want or need to do it. Depends on how you proceed after the game is completed in flash. You could call a javascript from the flash game and do some simple ajax to call a php script. I remember you can simply use the trick: getURL("javascript:saveGame('game1', 2332, 109233)"); Easy enough if you know how, but there's many resources out there. More advanced would be to use some connector or comunicate back and forth with callbacks. But just some pseudo code: // on the page where the flash game is using jquery function saveGame( game, userid, score ) { $.ajax({ url: '/ajax/saveGame.php', type: 'post', data: { 'game': game, 'score': score, 'userid' : userid }, dataType: "json", onsuccess: function(data) { if( data.status == 1 ) alert( "GameSaved!" ); } }); } Then some simple php under /ajax/saveGame.php // bootstrap PW index include( "../index.php" ); // get some fuel; create PW variables as if in a template file $sanitizer = wire( "sanitizer" ); $input = wire( "input" ); $pages = wire( "pages" ); $users = wire( "users" ); $game = $sanitizer->name( $input->post->game ); $score = (int) $input->post->score; $user_id = (int) $input->post->userid; // get the user object $user = $users->get($user_id); // do some magic; // if successful echo json_encode( array( 'status' => 1 ) ); Or you could simply use a getURL to redirect to a certain page after game is completed. You could add a get var to the url, read that out in php and use it to save some informations. /some/url/?game=game1&score=42 Then in the php template script use $game = $sanitizer->name($input->get->game); $score = (int) $input->get->score; Or if you use a php file that is not connected to PW use the bootstrap, as in the previous script, to get access to PW through using "wire()". Edit: Oh and hello Chad, welcome to the forums!
  7. Try something like this: <?php if ($user->isLoggedin()) { $out = 'You are already logged in.'; } else { // get id var from request $requested_id = (int) $input->get->id; if ($input->post->user && $input->post->pass) { $user = $sanitizer->username($input->post->user); $pass = $input->post->pass; if ($session->login($user, $pass)) { // login successful $t = $pages->get($requested_id)->path; $session->redirect($t); } else { $out = 'Login Failed. Please try again.'; } } $out = '<form action="./?id='.$requested_id.'" method="post">'; $out .= '<input type="text" name="user" value="Username" />'; $out .= '<input type="password" name="pass" value="Password" />'; $out .= '<input type="submit" name="submit" />'; $out .= '</form>'; }
  8. I'm not sure if that's what you looking for and if you already know it. Since users are like pages you can just populate or assign a value to a field and then save it. Checkboxes have state 0 or 1 vor checked. Assuming the checkbox field is the "game1completed". $user->game1completed = 1; $user->save(); This should work That's ok the way you do it, though not very scaleable and flexible. This approach may work if you only have 3 games and there wont be any more ever. There's other ways of doing it without checkbox. 1. Using a page that stands for a game. So you could create a template with only the default title field and call it "game-completed". Now you create pages for each game using that template somewhere. If you now create a page field "games_completed" that allows multiple pages for that particular template and assign it to the user template. Then you use that field to save and add a reference to the game the user completed. // get game page using it's name or id or path $game = $pages->get( "template=game-completed, name=game1" ); // assign the game page to the page field on user object $user->games_completed = $game; $user->save(); To check the pages // to see if or what games the user completed foreach ( $user->games_completed as $game ) { echo "Game:" . $game->title; } // or to output users that have completed a particular game $game = $pages->get( "/games/game1/" ); $users_completed = $users->find("games_completed=$game"); foreach ( $users_completed as $u ) { echo "User:" . $u->name; } 2. You could also use a textfield to store the game informations as JSON encoded string. And read the string and decode it when needed. But this way it would not be possible to use nice selectors and not so flexible. 3. One that would allow for saving games, along with some informations like score and time, would be to create pages for each game completed as children of the user page. Create a template "game-saved" that has the fields needed for the meta information. Then create new page when saving the game using this template and the user as parent. To be able to add child pages to the user pages, you first need to allow children for the system "user" template (use filter on template list to see it and edit it) under family tab. // create new page $game = new Page(); $game->template = $templates->get( "game-saved" ); $game->title = "Game1"; // parent is the user page (user = special page) $game->parent = $user; // assign some values $game->score = $somevar; $game->time_completed = $timevar; // save it. $game->save(); Checking for games could be like this $game1 = "game1"; // get all users that have completed "game1" foreach( $users as $u ) { // check if user has a child page using the name "game1" if( count( $u->children->find( "name=$game1" ) ) ) { echo "User: " . $u->name; } } To output game informations // or cycle the completed games and output if( $user->numChildren ) ) { foreach( $user->children as $game ) { echo "Game: $game->title<br/>"; echo "Score: $game->score<br/>"; echo "Score: $game->time_completed<br/>"; } } else { echo "no games completed"; } The field is yours.
  9. yellowled is right, Ryan commented it out in implemented version. https://github.com/ryancramerdesign/ProcessWire/blob/master/wire/modules/Fieldtype/FieldtypeDatetime.module#L76 "Timestamp" was in the patch Ryan provided as download.
  10. Ryan was talking about the URL when you logged in, refering to your "blank" page. Anyway, it looks to me as the id from the url isn't submited by the form. A simple debug "echo $input->get->id;" and commenting out the redirect would show that there's no id. So I'd guess, the form action should contain the id so it gets submited by the url.
  11. My favorite type of links recently are like: $p->setOutputFormatting(false|true); Simple to look on cheatsheet for reference. I recommend to have it open in your browser all the time
  12. Ah ok , have you tried to debug anything yet? For example where does the id come from? Output the path you are redirecting, is it correct?
  13. What does not work? Can you please provide more infos? Any errors? Debug enabled? As Ryan said, the session redirect doesn't work if anything is already rendered before your code. I don't think this code is the only there is. If this code is included in some or has some header.inc that already has html code it will not work.
  14. Maybe a well build html structure that suites well for theming only through CSS. Like zen garden.
  15. If such a case google search is better... https://www.google.ch/#hl=de&output=search&sclient=psy-ab&q=site:processwire.com%2Ftalk+404+error&oq=site:processwire.com%2Ftalk+404+error
  16. Marty, great work as always. I noticed that the french pages use english titles in the url. Not sure if it's intended or not, but would be easy and make sense to have speaking urls.
  17. This should do it throw new Wire404Exception();
  18. @Nico, the module knows it because you have to enter it. We use the language page title field.
  19. Weird when I tested this with getModuleID, It'd always return 0.
  20. Yes if I disable debugging it works... which means when I turn it on (always on when developing) the multilanguage doesn't work on frontend and admin. :/ And I love debugging enabled when developing. It also breaks the admin, this particular one appears on all pages even frontend. If adding the check wouldn't harm anyone I would be thankful.
  21. Well it seems it only works if you use the process module id. But no idea how to get that. As far as I know the process is handled through names. Look at admin.php in core. Edit: So only solution I see for now is looping and checking for $page->process == "ProcessName".
  22. Not sure, have you tried adding "include=all" ?
  23. Well I tested it quickly. Since the caching seems to be handled by $page->render(), it makes sense anyway to use it for rendering the page instead of the include. $page = $modules->get('LanguageLocalizedURL')->parseUrl(); echo $page->render(); This works with caching pages.
×
×
  • Create New...