Jump to content

Jan Romero

Members
  • Posts

    612
  • Joined

  • Last visited

  • Days Won

    15

Everything posted by Jan Romero

  1. Feel like you left out the most interesting parts there It sounds like you’re not using jQuery, but if you did, Ajax requests would return Deferred objects that expose done events. You could then use $.when to bind these Deferreds together into a single Deferred that fires such an event once for the entire queue, once all “inner” Deferreds have finished. I recently had to wrap my head around this. Voodoo is an apt description. I think in vanilla JS (I hope this is not the name of some JS library ) you would create an XMLHttpRequest object for each request, whose onreadystatechange events you handle in one function. There you could naively count the successes in a global variable and do your thing once you have all of them. So it kinda depends on what the requests look like and what events you can subscribe to. The requests should run in parallel if you simply send() them one after the other, i. e. the program will not wait for the server response until it executes the next request.
  2. I love all of those, but I can’t help but notice how the dignified feel of Eat-Drink-Royal is undermined by the neglected typography. Consider installing SuperSmartypants if you have no control over the texts. Here’s a comparison of the original and two versions with curly quotes and hairspaces: Gotta love that her name is Quayle. It’s far too rare that typefaces get to show off a capital Q, arguably one of the most beautiful characters in any font.
  3. The log will be in /site/assets/logs/errors.txt, or in the setup tab in the admin on newer dev-branch installations.
  4. That’s in the module settings for the core module ProcessField /processwire/module/edit?name=ProcessField
  5. What input type are you using? PageListSelect won’t allow custom selectors or custom PHP code. The Autocomplete input type doesn’t support custom code either. If you put return $page->children; as the custom php, it should totally work.
  6. I updated my post above. Apparently you need a closing php tag at the top, so it doesn’t expect php code. Disclaimer: I have only tested this with a PW and module version from about a year ago.
  7. You need to echo the html markup within your outer php tags as strings. Or you can probably just get rid of the outer php tags. <?php echo '<div class="row fullWidth img">'; echo ' <img src="' . $config->urls->templates . 'img/header.jpg" alt="header-picture">'; echo '</div>'; ?> <!-- OR simply: --> ?> //just a closing tag here <div class="row fullWidth img"> <img src="<?php echo $config->urls->templates; ?>img/header.jpg" alt="header-picture"> </div>
  8. Sure it’s possible. I’d love to see a more page-field-like PageTable, actually. Here is a (really, seriously) half-assed module that lets you add a page to a PageTable field. Be aware, when you remove your page from the field, it will trash the entire page just like the standard PageTable does. Do NOT use this anywhere but in a testing environment. It also has a hard coded template that you shoult probably change to whatever your PageTable accepts. $this->addHookAfter('InputfieldPageTable::render', $this, 'PageTableRender'); public function PageTableRender($event) { $pageTable = $event->object; $out = "<select name='{$pageTable->name}_addcustom'>"; $pages = $this->pages->find('template=PAGETABLETEMPLATE'); //change this foreach ($pages as $p) { $out .= "<option value='{$p->id}'>{$p->title}</option>"; } $out .= '</select>'; $out .= "<script> $(document).ready(function(){ $('select[name=\"{$pageTable->name}_addcustom\"]').change(addPage); function addPage() { var input = $('input[name=\"{$pageTable->name}\"]'); var container = input.siblings('.InputfieldPageTableContainer'); var dataurl = container.attr('data-url'); var pageid = $('select[name=\"{$pageTable->name}_addcustom\"]').val(); var ajaxURL = dataurl + '&InputfieldPageTableAdd=' + pageid; $.get(ajaxURL, function(data){ container.html(data); container.effect('highlight', 1000); }); alert('wtf did you do'); } }); </script>"; $event->return .= $out; } As you can see, the heavy lifting in the PageTable field is done via Ajax. Maybe it’s a starting point. I really need to go to bed
  9. The same disclaimer applies to me, obviously, but you may also want to hook into execute() in ProcessLogin, or, if you’re using the dev version, create your own alternative ProcessLogin. It’s used as an example on the blog.
  10. This is a great feature you can use to achieve what you want. It basically allows you to generate multiple versions of markup for the same template. There are of course more ways of doing something like this, but render options and partial template files will take you very far, with very clean code.
  11. When you put a page field inside a repeater, the $page variable that field gets is the page you’re editing. Not the repeater page the field actually belongs to. Put another way, the $page variable will be the same as $repeateritem->getForPage(). What you want, however, is $repeateritem itself. Honestly, I doubt this is possible out of the box. Like you said, if you used “real” pages in a PageTable field, you would edit those pages in a modal window. I. e. the $page variable supplied to the page field’s custom select code would be the current PageTable item. I don’t want to be the guy who misses the point and answers “why don’t you just do something else”, but PageTables are so much cooler than repeaters anyway. Any specific problems that stop you from using those?
  12. What Ryan described earlier in this thread sounds like exactly what you want? You get a text input where you can just write whatever (thus “free” tagging). That way you don’t need to create pages, but your tags are of course more prone to typos and you have to use urlSegments or GET parameters to show matching pages.
  13. If you have created your own ProcessModule for this, you can add the “permission” property to its module info. Only users with the set permission will load the module. The admin page will be hidden for everyone else. You can also set up your module so that it creates the permission on installation, and automatically removes it when it is uninstalled.
  14. $config->ajax uses $_SERVER['HTTP_X_REQUESTED_WITH'], which isn’t sent with JSONP requests. You can just check for $input->get->callback on the server side to determine if it’s a JSONP request.
  15. Yes, that should be fine. Even if $infoBox had multiple children, this should work and give you the first child. Perhaps the problem lies somewhere in the structure of your function. Would you mind posting the complete function? Is there anything else you do with the $child variable? By the way, the links on your site seem to work right now?
  16. Seems like the translation JSON is corrupted. Under Languages->Français, can you click on the json file you’re trying to use and verify that the first two properties, file and textdomain are present and correct? It should look like this: {"file":"site\/templates\/theCoolestTemplate.php","textdomain":"site--templates--thecoolesttemplate-php","translations":[…]}
  17. I’m not exactly sure if that’s what you want, but if you just want to generate a bunch of nested <ul>s, you should recursively travel around the page tree. Something like: function siteMap(Page $root) { $out = "<li>{$root->title}"; if ($root->hasChildren) { $out .= '<ul>'; foreach($root->children() as $child) { $out .= siteMap($child); } $out .= '</ul>'; } $out .= '</li>'; return $out; } Uuuuh… at least I think that should work. Untested It should give you the complete branch starting at whatever you plug into $root. edit: Actually. Something is bound to be wrong with this. And you need to supply the outer <ul> yourself. edit: Tested it. Fixed it because it was stupid.
  18. Ah. You’re overriding ProcessWire’s $user variable here: $user = $sanitizer->username($input->post->user); Now $user is just some string the visitor entered, and no longer the special user object. Just use a different variable like $username or something. The same thing applies for other API variables like $page, $pages, $session, etc. as well, of course.
  19. Indeed. Without really looking into it, the Javascript must depend on the position of the buttons. Try this to insert the buttons inside .InputfieldPageTableContainer: public function PageTableRender($event) { $return = $event->return; $from = strpos($return, "<div class='InputfieldPageTableButtons"); $to = strpos($return, "</button></span></div>", $from); $buttons = substr($return, $from, $to-$from) . "</button></span></div>"; $insertAt = strpos($return, "<table class='AdminDataTable AdminDataList'>"); $event->return = substr_replace($return, $buttons, $insertAt, 0); } Instead of this hackish string trickery, perhaps a better way to clone/move the buttons would be to use Javascript in the first place. I’m not sure how to best pull that off. Just append a script tag to $event->return?
  20. There is probably a more robust way to do this, but, uh, I tried $this->addHookAfter('InputfieldPageTable::render', $this, 'PageTableRender'); public function PageTableRender($event) { $return = $event->return; $from = strrpos($return, "<div class='InputfieldPageTableButtons"); $to = strrpos($return, "</button></span></div>", $from); $buttons = substr($return, $from, $to-$from) . "</button></span></div>"; $event->return = $buttons . $event->return; } The Inputfield’s original render method puts the button html in the variable $btn, but I suppose there’s no way to just access that one. Another way to duplicate the button elements would be to just copy the code that generates them.
  21. Interesting approach to tagging You’re trying to specify the parent by name, but I’m pretty sure ProcessWire would much rather have a page ID or a path (meaning, wrapped with forward slashes). Because PW can tell “genre” is not numeric (so not an ID), it treats it like a path, as if the slashes were there, but there are no tags under “/genre/”. They’re under “/tags/genre/”. So try that and it should work. Alternatively, specify that you’re selecting by name: $genres = $track->tags->find("parent.name=genre"); I can see how this can seem confusing, because when if you were looking for a direct child of the homepage, it would work. In that case, the path is the same as the name with slashes. Because you’re not really selecting “dynamic” pages here, but rather pages that are a fixed part of your site’s structure, you might want to use IDs instead. That way, if you later want to change a page name/path, you can do it comfortably in the admin, and don’t have to go around fixing your selectors.
  22. (I said “the following readme” because I was going to paste it until I saw your edit) By the way, if you use a template without a file, pages using that template will show the 404 page automatically. You should probably look into what’s causing the error in /about/’s template.
  23. Check out the folder called “errors” in your template directory. You’ll find 500.html and a readme.txt. This html file will be displayed when a fatal error occurs, and you can customize it. To manually cause the 404 page to show, you can throw this exception in your template code: throw new Wire404Exception(); However, it sounds like this recipe might suit your needs better than a 404 error page: First child redirect on ProcessWire Recipes. It’s just a single line: if($page->numChildren) $session->redirect($page->child()->url); die();
  24. If you don’t set a template file, the URL will show the 404 page, as if the page didn’t exist. Logged in users would still be able to view the page’s content in the admin backend. If you want to have a page with a visible template that can’t be accessed by guest users, you can check if the user is logged in. If not, you throw a 404 Exception. <?php if($user->isLoggedin() != true) { throw new Wire404Exception(); } // normal template code
×
×
  • Create New...