Jump to content

Pete

Administrators
  • Posts

    4,035
  • Joined

  • Last visited

  • Days Won

    66

Everything posted by Pete

  1. A single "=" will only work in PW's selectors like $page->find('something=something') and so on - you must have double == to compare values in normal PHP as per the link I posted. Strange that that's not working either though, but a single "=" is definitely wrong. Just a thought - what is the expected value of $page->project_url? If it's just a text field then you might want to check it's not empty with if (!empty($page->project_url as it would exist whether empty or not, so simply doing if ($page->project_url would always be true I think. If on the other hand it is a Page fieldtype, then try if ($page->project_url->id instead.
  2. In what way doesn't she like thumbnails? If she means that she would prefer a gallery to open with just the first image showing and controls to get to the next one then it's not too bad - the first image will load first and the others will load afterwards, meaning that the load time is irrelevant as long as the user sees that first image pretty much right away. Does that sound more or less like what she's after? The issue then is the one you've spotted already - there would be an SEO hit because of the total page load time. Just to get a bit more info on the layour, how would the category list be displayed? Is it a set of text based links that, when clicked, open up the relevant category of images? A solution if that is the case would be to somehow (all theoretical ) have it load a modal window via Ajax that fetches the first image and displays buttons to load the next image in that modal window, also via Ajax. You're then also into other tricky SEO territory as whilst Google is trying to follow what goes on with Ajax nowadays I'm not sure how good the support is yet. You'd certainly get quick page load times for this idea though, as it would load the first image when it's requested, as with every other image, though I couldn't guess how you'd go about linking together multiple Ajax modal contents off the top of my head - maybe not the most helpful suggestion As for better advice, my choice of lightbox is almost always FancyBox and it's also used in the PW admin. Version 2 is worth a look as it's newer.
  3. Wasn't aware that you could call a module path via config that way - you learn something new every day Ryan - MailChimp has it's pros and cons like any other email newsletter system, but the API is pretty good which makes doing things like what Arjen's building pretty easy. Since getting into ProcessWire I find it a chore if I have to use a system with an even remotely complicated API (you heard me LemonStand, I mean you among others - but I still love you ).
  4. You can simply use the pipe character to separate them. I would do something like this: echo '<form action="./" method="post">'; // Change the action to the results page foreach ($page->children() as $category) { echo '<input type="checkbox" name="categorylist[' . $category . ']" value="' . $category . '"> ' . $category->title; // $category is the same as $category->id by the way } echo '<input type="submit" value="Submit" />'; echo '</form>'; Then your selector would be something like: $categories = implode('|', $_POST['categorylist']); // This is an array of the checkboxes that are ticked from the previous page $pages->find("id=$categories"); It's as simple as that - you can just use the pipe character: | to separate values you want to match against. More details are under OR selectors: matching one value or another about halfway down this page: http://processwire.com/api/selectors/
  5. I like the idea of this, however have a few suggestions before I go too much further: I think it might make more sense to call it NewsletterMailChimpSync.module as I initially thought it was a full integration that could send out newsletters as well Specifying exactly what it does in the module name also allows other people to build MailChimp modules to perform other tasks too using a similar naming convention. What is this config setting and where does it come from? $this->config->urls->NewsletterMailChimp - that's not in a default PW installation. In relation to point 2, it would help if we had a copy of the MCAPI class too to test this out and provide more feedback Now I know what it does, it's still pretty cool. As for point 1 on your list, you should be able to add this to your init() function: include_once($this->config->paths->NewsletterMailChimp . 'mailchimp/MCAPI.class.php'); // Get mailChimpApiKey and set url $apikey = $this->mailChimpApiKey; $this->api = new MCAPI($apikey); Then you can call the api in any other function via $this->api $apiUrl didn't seem to be used so I removed it from that example.
  6. A handy bit of info on comparison operators: http://php.net/manual/en/language.operators.comparison.php In your case you're making $page->show_url equal to 1 regardless of it's true value by setting it to 1 using just one '=' whereas you need two '==' to compare the field value against another value. Granted, PW's selectors only use one = but they're a bit special like that
  7. Something like this should work: // First iterate through all of your categories (I'm assuming they all have a template called "category", but this could be changed to suit $categorycount = array(); foreach ($pages->find("template=category") as $category) { // Now I'm assuming that the portfolio pages have a template called "portfolio" and are tagged against a category using a field called "category" $categorycount[$category->title] = $pages->find("template=portolio, category=$category")->getTotal(); } And that should be it - an array of category titles and their corresponding portfolio page counts. In the above code, we're first iterating through the categories, then finding all pages in the portfolio with a category that matches the current category we're looping through. Note that it seems like you would have to use $category->id, but if you omit the field you are outputting for a given page object it will default to ID anyway Oh, and the above is untested but should hopefully work EDIT: It's also worth noting that I had to refer to the cheatsheet as I couldn't remember the correct method to get a total - turns out it was getTotal() The cheatsheet is an invaluable resource even to those of us who have been here a while so if you've not seen it yet then check it out.
  8. $page->images would only work of your images field was called "images" otherwise as you say it would be "the_image_field" if that's what you called your image field. $page->image_field_name->url gets you the URL and ->description on the end instead of url gets you the image description if you entered one.
  9. That's pretty epic. If there's one film you watch this year with Hulk in, watch the Avengers movie - Hulk steals the show!
  10. I think I hard-coded this into a module I wrote a while back so having an actual fieldtype for it is definitely handy
  11. Yeah, it's alright I suppose @ryan - thanks for this as it's perfect timing for a few things I'm intending to do too
  12. Images are tied to a page and repeaters are essentially special hidden pages, so I think that's expected in this case. Can I ask what the usage is in this case? It's just that for most pages you wouldn't have image fields inside repeaters in order to use images in the main page's body text - an image field attached to the main page could store as many images as you like to insert into the body text. If you let us know the fields in your page and the fields in the repeater we could possibly suggest some other ways of achieving what you're trying to do
  13. Is there another htaccess inside Piwik's folder that might be interfering?
  14. To be honest it might just have been server incompatibility in my case, but it was blocking legitimate users too and it was a reasonably wavy traffic site with users from across the globe so when some legit users were being flagged and I didn't have time to look into it further it was easier to turn it off. I will definitely revisit it in future as the concept is amazing and the price is great (free).
  15. I wouldn't do it that way though if it's going to be the case that you have pages in multiple locations a lot of the time. Take for example your first structure - most ecommerce packages would handle this y creating the category structure, then adding products and ticking a box in a category lost to assign that product to multiple categories. When browsing the structure you would have a URL of vacuums/wet-vac-cleaning-solutions and under that it would list your product, but when you click on the product it would appear at a URL of something like products/super-clean-2000 I would suggest handling it this way as well, as I'd you use redirects you're essentially taking the user from one category to a completely different category which would make them a bit confused I think. As such, I would make the structure of your categories under a page called "categories" and create a template for those pages called "category". Then create a page called "products" and a template called "products" for it to use. The product template would need a field called "categories" that uses the Page fieldtype which is set up to allow selection of all pages under the category page. You then simply add products and select the categories they appear in When editing the front-end categories template to show the relevant products in that category you can simply use a selector to find all products that are in that category. Sorry, that's a whistlestop tour of how I'd recommend doing it and doesn't sound simple, but it is pretty easy in reality and not as daunting as I've probably just made it sound
  16. I never quite got Cloudflare working properly - it worked, but it was blocking legitimate users and caused me issues in PW admin so I quickly turned it off. I think if I approach CloudFlare again I'll definitely do a lot more testing first to try and smooth out the kinks!
  17. Silly question, but are the permissions set correctly on Piwik's folder and files? That would be my first guess. Also might be an idea to test temporarily by selecting and cutting all the contents of your .htacess file so it's blank and see if that allows you to access Piwik, then put it back to how it was quickly (assuming it's a live site).
  18. If you add a hook before page save you don't need the last line where you save the page (it'll do that anyway), otherwise it will infinitely loop as you're making it go in circles. Take out $p->save; and it should be fine.
  19. It's not particularly relevant here as something like the above should be fine for a one-off URL, but it might well be possible to create a configurable module in future if this sort of scenario arises again. I can see a simple textares config field with this being able to work for multiple templates, one per line followed by fieldnames to concatenate: template1name,field1name,field2name,field3name template2name,field3name,field1name,field7name That's the easiest way I can think of to do it for multiple templates in the same site and have it configurable with no code edits. Of course the module code above would have to become more complicated to support that, so for a one-off stick with the code above - I'm just thinking out loud and once again being pleasantly surprised by the fact that anything seems possible with ProcessWire.
  20. I'm not of much help on the rest of this topic, but since you asked Soma I think the phrase you are looking for is "level of complexity". Your English is still infinitely better than my Swiss
  21. It won't affect images or files attached to the page if you change the title or name fields - it's all tied together using a unique ID so you can rename things as much as you like. You would need a custom module to auto-generate a URL concatenated from the fields in question and it would depend on how you have certain things set up. I would suspect Make and Model would be Page fieldtypes (see this video, but you'd want to set it up as a Select or Autocomplete rather than a multiple select). The title field itself would be best left as a stock number I think as this can easily be outputted as something like "Stocknum - Make Model" in the <title> tag in your template (which I'm guessing you've already worked out), it's just the URL you'll need a module for and you'll be happy to know that even that shouldn't be too hard. The module would be something like this: <?php class BuildUrl extends WireData implements Module { /** * Basic information about module */ public static function getModuleInfo() { return array( 'title' => 'Build URL', 'summary' => 'Builds a URL on page save based on specific fields.', 'href' => '', 'version' => 001, 'permanent' => false, 'autoload' => true, 'singular' => true, ); } /** * Populate the default config data * */ public function __construct() { } /** * Initialize the module and setup hooks */ public function init() { $this->pages->addHookBefore('save', $this, 'buildUrl'); } /** * Checks if we're in maintenance mode and performs any neccessary redirects * * @param HookEvent $event */ public function buildUrl(HookEvent $event) { // Accesses the $page object $page = $event->object; // We only want this to apply to a certain template if ($page->template->name == 'yourtemplatename') { $page->name = $page->make->name . '-' . $page->model->name. '-' .$page->stocknum; } } } The code above is untested but should give you a bit of a head start. The code only wants to run before save on a page using a certain template - it then gets the name from the "make" field (so it checks the make and fetches the name value from that associated page) and the same for the "model" field, then attaches the stocknum field (just a plain text field I guess) to the end, concatenated with hyphens. Because it runs before page save there's also no need to call save, but some extra checking would be advantageous as some of those fields won't be populated when the page is first saved (i.e. brand new). To install the module, whack that code in a file called BuildUrl.module and place it in your site/modules directory. Then go to the modules section of the admin and check for new modules, then install it (after making changes to suit your fields and template name). EDIT: Some of the settings at the top (autoload, singular) might not be right as I was doing this in a hurry and don't have more time tonight, and I'm not sure the empty __construct function is required, but left it in in case it broke without it. I'm sure someone else who's around later will improve on it with other suggestions
  22. The inputfield and process ones are specific to those modules so it makes sense that they're separate, even if they're core modules. That said, minifying them would save a few seconds on each admin page load - the question is how easy that would be to do (I'd use the PHP minify project personally, but doubt that can be distributed with PW?). It might make things a bit snappier where larger numbers of different fields are concerned, but even with that it's not exactly sluggish (though my live site list of files that's simialar to yours above is only 4.6 seconds max and that's not even localhost!).
  23. He's using the mouse left-handed - he should be using his right hand Where's WillyC with his words of wisdom when you need him?
  24. I suppose in practice I probably do the same as Thomas actually
  25. Pete

    RoR

    RoR was really big a few years back with a lot of hosting companies scrambling to support it on their servers - presumably to cash in on the craze. I've just not seen much done with it though. If someone asks you to code in it and you're trying to get back to the safety and comfort of PHP, it's always handy to be able to say things like "Google and Facebook both use PHP and look what they can do". Obviously it you're talking to a client who's part of a large organisation, half their staff may be on Facebook most of the time so probably best not to mention that one and stick with Google as the example
×
×
  • Create New...