Jump to content

ryan

Administrators
  • Posts

    17,100
  • Joined

  • Days Won

    1,642

Everything posted by ryan

  1. ryan

    Hijackers

    Amazingly these are just the accounts that get through the 1) Captcha image (on most difficult-to-read setting), and 2) email verification. I don't know what the purpose is, but apparently a lot of forums get hit with these same accounts because stopforumspam.com nearly always recognizes them. A large amount of our spam accounts come from China for some reason. I don't think we have any legitimate current ProcessWire users in China (?) right now, but I'm hopeful we'll have lots in the future.
  2. ryan

    promoteka.hr

    Great site Nikola! Nicely done. Thanks for posting this. Amazing this is your first site with PW, looks like you are already a pro with it.
  3. Good idea. I think we're going to get much deeper into locales and internationalization very soon.
  4. Strangely I couldn't get it to work before (must have been something up with my browser). It works great now. Seems like quite a nice solution they've got here. What's your opinion of this vs. Aloha?
  5. Great job! I look forward to trying out this module. Thanks for the great screencast too.
  6. I'm interested to know what you find here. I'm no expert with JS debugging, so ignore this if it sounds obvious. Placing a console.log(event) in your onchange event handler may make it easy to find, but might not help much if the page gets immediately loaded/reloaded. So an old fashioned alert() after a console.log of the event will pause everything and might make it possible to see what is doing the change.
  7. Marty, looks good except that page reference fields in a selector expect a page ID (number). If your $urlcat variable represents the page ID, then your example will work. However, I'm pretty sure that's not the case in your example. Also, I don't personally like using page ID numbers in URLs, much preferring to use the name, which is more meaningful. So assuming you agree, here's what you'd want to do (below). This is your example, but I just added one line: <?php if($input->urlSegment1 == 'categories') { if($input->urlSegment2) { $name = $sanitizer->pageName($input->urlSegment2); $urlcat = $pages->get("/categories/")->find("name=$name"); // this is the only line I added $notes = $pages->get("/notes/")->find("template=notes, sort=-publish_date, note_category=$urlcat"); foreach($notes as $note) { echo "<p>{$note->title}</p>"; } } }
  8. PW will adapt wherever you put it, whether on a subdirectory, different domain, subdomain, etc. You don't have to tell it anything about where it's running because it figures it out at runtime. It's a little harder to design the CMS that way (which is why most CMSs don't do it), but I think it's well worth it. Likewise, it doesn't care whether it's being accessed by HTTPS or not unless you specify that you only want one or the other in your template settings. Because you are using a different domain for HTTPS, you'll want to skip using that template setting and instead do this: To detect if the request is coming from an HTTPS connection: <?php if($config->https) { // user is on an HTTPS connection } else { // regular HTTP } If you wanted to logged-in users to always redirect to the same page at a different domain, you'd do this: <?php if($user->isLoggedin && !$config->https) { // redirect to the same page at the alternate https domain $session->redirect("https://clientname-fi.pwire.fi" . $page->url); } else { // user is in the right place } You probably want to put that in some universal/header include file so that you don't have to code it in more than one spot.
  9. I've just added it to ProcessPageSearch and committed the update to the P21 source. Now you can do something like this: var url = config.urls.root + 'page/search/for?template=basic-page&body*=something'; $.getJSON(url, function(data) { console.log(data); }); The example above shows "search/for?" as the URL. When you add the "for" to it, it assumes that you are going to specify a selector in the URL. This works with either Ajax or regular mode. In ajax mode, it returns JSON. In regular (non ajax) mode it's going to output the results in interactive/html mode as usual. This "selector mode" isn't used in the search engine by default, so it's only used when you include the "for?" in your URL and specify a selector after it. I believe this selector mode is much more convenient than the regular mode for AJAX use, as well as regular non-ajax links to the search engine. The selector can be identical in format to a regular selector with the only difference being that you separate each part of the selector with a "&" rather than an ",". Here is an example: /processwire/page/search/for?template=villa&body*=luxury&bedrooms>5&bathrooms<=3 The above is a valid URL, but it's also a valid selector. If we replace the "&" with ", ", then we get this: template=villa, body*=luxury, bedrooms>5, bathrooms<=3 PW abstracts away the parsing of GET vars that lack an equals sign, like "bedrooms>5", and translates all of PW's 2-character operators just fine too (like *=, ~=, %=, <=, >=). Of course, you can also do this (specify a parent path): /processwire/page/search/for?parent=/path/to/parent&featured=1 If you want to specify what fields should appear in the JSON output (or the interactive table), then just add a "get=" var to your URL, like this: /processwire/page/search/for?template=basic-page&get=title,path,categories Separate out the fields you want to "get" with commas, like above. When you specify what fields should be included, it will include them in the output, in addition to the native fields that are included in all (like id, name, template, parent, etc.). Because JSON can represents objects nicely, PW will also include partial objects (like page references) as JSON objects. For something like a Page reference, it'll include most of the native fields for each page, as well as the title and path. By default it will paginate by 50, though you can increase that up to 250 by specifying your own "limit=123" var in the URL (where 123 is the limit you want to specify). To retrieve the next pagination, specify the same limit but precede your URL with the page number, i.e. /processwire/page/search/for/page2?template=basic-page&limit=100 If you prefer, you can specify a "start=123" var in your selector (just like with other PW selectors), to indicate the result number you want to start from. But I'm guessing most will prefer the simplicity of using the page number pagination. If you call jQuery's getJSON() on the search URL, you will get your results in JSON format. Here's an example of a call we might use: $.getJSON("/processwire/page/search/for?template=basic-page", function(data) { console.log(data); }); jQuery's getJSON automatically converts it to an object in jQuery, but the JSON string is probably the simplest way to envision it, so here is the actual JSON string as it's returned from that query. This query was performed on a stock install of PW 2.1 using the included profile. <?php // ignore the PHP tag, I just wanted syntax highlighting { "selector":"template=basic-page, limit=50", // just a repeat of the selector you used "total":"4", // total number of results found. if there were 1230 matches, this would be 1230 "limit":50, // the max number of results that will be in this request (default=50) "start":0, "matches":[ // array of matches { "id":1001, "parent_id":1, "template":"basic-page", "path":"/about/", "name":"about", "title":"About" // plus any fields you specify with get=... }, { "id":1002, "parent_id":1001, "template":"basic-page", "path":"/about/what/", "name":"what", "title":"Child page example 1" }, // and so on for each match ] } I'm sure there are tweaks and improvements still to be made, so please let me know if you find any issues or areas for improvement.
  10. ryan

    Hijackers

    I missed the spam post, thanks for taking care of that. We get 50+ new spam accounts per day, and the stopforumspam blacklist takes care of nearly all of them. But I do have to go in and delete all the filtered accounts every week or so. 600+ accounts means it's time for me to delete them (tomorrow).
  11. Great! thanks for testing, I will commit.
  12. Some properties are only populated at page load time. When you create a new page in memory and save it, that page has still never been loaded from the database. As a result, it won't have created/modified properties since those are DB generated. PW doesn't automatically reload a page from the DB when you save it. But you can reload it yourself: $page = $pages->get($page->id); However, I think an even better strategy is to perform a redirect after you've committed any kind of major changes. That ensures that you are dealing with a fresh copy of everything and prevents a browser reload/refresh from re-posting your form and potentially creating a duplicate. So I would do something like this: <?php $template = $templates->get('new_page_template'); $parent = $pages->get('/path/to/parent/'); if($input->post->submit == 'save') { $p = new Page(); $p->parent = $parent; $p->template = $template; // ...populate the page... if($p->save()) { $session->newPageID = $p->id; $session->redirect('./'); } else { echo "error saving page"; } } else if($session->newPageID) { $p = $pages->get($session->newPageID); // a little security check, that may not be necessary since we're using $session // but i always veer on the side of more security. if($p->parent->id == $parent->id && $p->template === $template) { // display the results } }
  13. Attached is an entire Fieldtype and Inputfield that show an example of 3 inputs for each image (title, tags and description). I've also set it up so that you can just change the schema in the getDatabaseSchema() function and it should automatically work with whatever varchar or text fields that you add. Though note that you'll want to make those changes before you create any fields with it. This works because the only place these custom fields are defined is in that schema, and everything else in the Fieldtype and Inputfield just picks it up from that schema. In the future, I will probably use this as a foundation for a more advanced image/file fieldtype where you can specify the schema from the field's configuration in the admin, rather than modifying the code. But figured this would be a good example for what you asked for. Ryan FieldtypeImageExtra.zip
  14. Soma I was wondering if you could try out this /index.php file attached and let me know if it fixes it on your end? Since I don't have an example like yours to test from I just wanted to double check before committing. Thanks, Ryan index.php.txt
  15. Okay cool so it looks like realpath fixes it. I'll make the update and commit it. Thanks!
  16. Have you tried it? I think it should work out of the box. At least, I can't think of any reason why it wouldn't. Let me know of any specific areas of concern. The only thing I can think of that may have to be a consideration is the https vs. http settings for each template. If you access a page on an http addr using an https-only template, it will redirect to the same URL but with https. That may not be a problem. But if you find it's creating any issues, you can always leave the template set at the default (which is to accept traffic from both https and http), and then perform your https check in your template using $_SERVER vars.
  17. I just updated my original message, wondering if realpath() fixes it. Not sure it'll tell you my message was updated, so you may have to click back to page 1.
  18. Thanks for sending that. Can you try this in your strap.php and tell me what the output is? <?php include("../index.php"); echo "<pre>"; echo $_SERVER['SCRIPT_FILENAME'] . "\n"; echo __FILE__ . "\n"; Here is the output on mine for instance (two of the same lines): /Applications/MAMP/htdocs/skyuser/test/index.php /Applications/MAMP/htdocs/skyuser/test/index.php I'm guessing yours are different and we may have to use realpath(). So if they are different, try this and let me know if that does it? <?php include("../index.php"); echo "<pre>"; echo realpath($_SERVER['SCRIPT_FILENAME']) . "\n"; echo realpath(__FILE__) . "\n"; Thanks for your help testing this.
  19. Thanks for posting this, it is really helpful for me to see! Hopefully I can duplicate and find a solution.
  20. Something like onkeyup may not be ideal not only because of the overhead but because those events may or may not represent changes (arrow keys being an example). Are you using the ed.isDirty check? My understanding is that is necessary in order to really tell if it changed. Below is quoted from the TinyMCE page on the onchange_callback: Also, make sure that you are just monitoring TinyMCE and not also the textarea separately. If the field is using TinyMCE, you will want your other code to ignore the textarea. These are just ideas and you may have already tried this stuff, but I'll keep thinking here too. TinyMCE is always a hassle no matter what we try to do with it, but thankfully it's always great once things work.
  21. Soma, can you try this test: 1. Create a subdirectory off of your PW installation directory, i.e. /test/ 2. Put this file in there: /test/test.php <?php include("../index.php"); echo $wire->pages->get("/some/page/")->url; If your site is installed at root, it should say: /some/page/ If your site is installed in a subdir, it should say: /subdir/some/page/ Are you getting something different? If so, what's the server environment? If you have phpinfo output that you want to PM me a URL to, that's all I would need to see. Also, double check that your /index.php is the latest version from yesterday (which is where this change was made). Very often when people (at least me) update their PW install, they just replace the /wire/ dir and not the /index.php, but this is one case where you'd need to replace the /index.php in order for it to work. Thanks, Ryan
  22. Marty, the possibilities are pretty much limitless here, so this can be structured however you want it. If I'm following your right, it sounds like you want to be able to list the categories in your Portfolio section even though they don't technically live there. That's no problem. Just edit your Portfolio index template, click on the URLs tab and tell it to allow URL segments. Now you can have our Portfolio index template look for categories and display items from them: <?php if($input->urlSegment1 == 'categories') { if($input->urlSegment2) { // example: /categories/work/architects/ // category specified, list items in category: $name = $sanitizer->pageName($input->urlSegment2); $category = $pages->get("/categories/work/$name/"); if($category->id) { // valid category, list items in it echo $page->children("categories=$category")->render(); } else { // unknown category echo "<p>I don't know that category.</p>"; } } else { // list categories echo $pages->get('/categories/work/')->children()->render(); } } else { // list all portfolio items echo $page->children()->render(); }
  23. Here's a little more info about the onchange_callback as well as the isDirty property (I meant to paste this in before): http://www.tinymce.com/wiki.php/Configuration:onchange_callback I doubt that the "live" is adding much overhead, though don't know for sure–but if one() works there that seems better. It was more the "input" event that I thought would be overhead heavy since it triggers on every character you type. I was just wondering if using 'input' (rather than just 'change') is necessary? (it may be, but wanted to check) I'm not sure I understand the current name because 'Check State' can mean a lot of things, and it's handling more than just the PageEdit form? I would probably use something like FormChangeMonitor or FormSaveReminder or something like that? But whatever you think is best. Your current name is certainly better than something like my PageLinkAbstractor module.
  24. Okay I think I've got it fixed. You'll want to grab the latest P21 commit, or if you prefer just the /index.php file from it. Thanks for finding this issue.
  25. I see what you mean. I can duplicate here too. I will work on this and post a fix shortly.
×
×
  • Create New...