Jump to content


  • Posts

  • Joined

  • Last visited

Everything posted by BUCKHORN

  1. How do I change $page->template->filename in a module? I'm using a the page render hook before and no combination of attempting this has worked. To further confuse me... I can't even set the variable in a template directly or using set().
  2. To do it your way, maybe use RedirectMatch in place of your first FilesMatch RedirectMatch \.(png|gif|jpg|jpeg)$ http://example.com/image_handler.php I think mod rewrite will be your ideal solution, several examples below that will get you close. Personally I'd rewrite all image requests to my proxy script, then store my allowed prefixes in an array and simply loop through the array. It's not the best solution, but it's simple and allows for some scalability. in .htaccess Redirect all images to proxy script RewriteEngine On RewriteBase / RewriteRule ^(.*)\.(jpg|png|jpeg|gif)$ watermark.php?image=$1.$2 [NC,L] in your proxy script watermark.php $prefixes[] = "thumb_"; $prefixes[] = "100x0"; foreach ($prefixes[] as $prefix) { if((substr(0,strlen($prefix)) == $prefix) xor ($user->isSuperuser())) { //return the image } else { //return a different image (maybe one that says access to this file is denied) } } Some rewrite examples that may help: Redirect requests that don't originate from the host www.example.com (stop hotlinking) RewriteEngine On RewriteCond %{HTTP_REFERER} !^$ RewriteCond %{HTTP_REFERER} !www.example.com [NC] RewriteRule \.(gif|jpg|png)$ /images/go-away.png [R,NC] Check for a login cookie and redirect if not logged in RewriteEngine On RewriteBase / RewriteCond %{HTTP_COOKIE} !CookieName= [NC] RewriteRule .* http://www.example.com/members/login.php [L]
  3. I had to leave Drupal behind, because it didn't serve my community. Basically it was too expensive and it's really starting to cater more to enterprise clients. I'll probably never use Drupal again, unless it's for an enterprise client with a big budget. Building a simple blog site is fast and easy enough by cloning an existing Drupal site, but the problem is the ongoing costs of maintenance. I can knock out a fairly robust Drupal site in a week and charge less than $2-5k, but at that price point, I'm not attracting clients who will pay the $2,500 - $5,000 a year to maintain (both the server and the software) and host Drupal (In my experience Drupal needs a dedicated or vps server for sites w/o any significant amount of traffic). My clients are small businesses and uneducated regarding their options. They think Drupal is the next WordPress w/o realizing it's not even close to being as simple, it's more expensive, and it's not all that easy to maintain. On top of that, Drupal devs charge between $90 and $175 per hour. From a business perspective, Drupal is fantastic (a cash cow). There's always an upsell, always a problem to fix, always a new update to apply (then fix). It's too bad I'm not it in for the money. I prefer to get paid less and enjoy the work I do (PW is fun, Drupal is a pain in the ass). I want to provide quality, charge a fair price, and work with great people, not dupe someone into buying a boat as it were, which is what I see a lot of Drupal web agencies doing. They don't choose the best platform for the client, instead they put them on Drupal... the recurring income stream because it's good for their business. Inexperienced devs/freelancers will do the same thing, but for the right reasons most of the time. They just don't have the experience with Drupal to know what problems lie ahead. The only advantages I see of using Drupal, -Drupal has a huge community testing and reporting bugs which makes it more stable, secure and more accessible to more server/hosting environments. -Drupal has a ton of quality free modules. -Drupal is great for enterprise clients. The costs at this scope are quite reasonable and Drupal seems to meet the needs of these clients very well (talking about huge companies). For example putting the .gov site in Drupal was smart, the whitehouse has the budget and resources to do the job right and they have a much better solution for the price than building something that large from scratch. My rule of thumb, if a client is getting 100K unique visitors a month, then consider Drupal, but also consider whether or not the client can afford it. If you sell someone a Drupal site that they can't afford, you will have nothing but conflict and unhappy clients. Sometimes too you need to consider the level of sophistication of the client. Even if a client has the budget, it's sometimes better to put them on a platform which grows as their understanding of websites grows. A way to illustrate this... Say I work at a snowboard shop and i have a customer who has only been snowboarding once. I wouldn't sell them them to top of the line board unless they insisted. Instead I'd try to get them to purchase a board that is more appropriate for beginners. Not only will the board be cheaper, it's not built for precision like the high end boards. The customer will have an easier time learning on the entry level board and have more fun as a result. If sold them the high end board, they may have difficult controlling it and fall a lot or run into a tree. To address some of your points on the difficulty of selling PW... My point is, change your sales strategy for each client. You may think PW is the best thing since sliced bread (it is), but if you are interested in being successful in business, sell people what they want, not what they need. They will be ecstatic with you and your services and you'll have a fat wallet and more work than you know what to do with. As your relationship with these people grows, you'll be able to move them to a better platform like PW when it's time for a new website or when they decide they need something that their current platform doesn't provide. My boat reference: A boat is a hole in the water into which you pour money.
  4. Great theme. Much improved. I'd like to see more padding and margins around clickable objects like the menu drop down and buttons, maybe even increase the font size. This is for mobile and tablet users. Is there a link to: Phillip Reiner's great admin theme design I think I've seen it before, and would also like something like it.
  5. yep, I didn't think about that and my workaround doesn't do you any good in this case. I had a look at the module and this is by design, but I don't think Ryan had considered the case where you may want a zero, but not negative numbers. I think it needs to be submitted as a bug. In the meantime, try commenting line 30 in wire/core/modules/InputField/InputfieldInteger.module and let me know if that works.
  6. This may also be useful: http://processwire.com/talk/topic/4602-flexible-downloads-using-pages/
  7. hmm, sounds like a bug, because zero is an integer. a workaround may be to leave the min blank in the fieldtype and use min="0" in the html5 tag in your template. <input type="number" name="quantity" min="0">
  8. Where are you setting the min in the html5 tag or is there a setting in the fieldtype?
  9. Private file handling is your solution. You would abstract all files from public access by doing something like... /files.php?file=myfile.jpg vs. /myfile.jpg Then in your private file handler you can check permissions and show the users the correct image according to their access level. I'm not sure if idea is native to PW.
  10. Check your server error log in case the problem is un-related to .htaccess. You may also find some errors in siteroot/site/assets/log/error.txt. What specifically about admin isn't working are you getting a 500 error, a blank page, etc? More info will help.
  11. You can create a repeater and allow users to upload a normal version of an image and a hd version. You won't need retina.js, however you'll need to pull out the hd detection and put it in a custom script that sets a session var or cookie or passes the variable to php via other methods json or ajax. <script> // hd detection // if hd enabled, set a cookie </script> Then when you loop through the repeater... foreach ($images_repeater as $image) { if (($_COOKIE['hd'] === true) && ($image->hd_image)) { //show hd image } else { //show normal image } } You could also just upload the HD version and let PW create the normal sized image. foreach($page->images as $image) { $hd = $image->width(500); $normal = $image->size(250); if ($_COOKIE['hd'] === true) { echo '<img src="{$hd->url}">'; } else { echo '<img src="{$normal->url}">'; } }
  12. I wonder if installing both sites in the same database using prefixes would work. e.g. s1_users, s2_users (s1,s2 are prefixes) maybe this structure e.g. s1_notshared, s2_notshared, shared_users (s1,s2,shared are prefixes) Both tables are in the same database so the same db connection could access them. Then you can use a hook or code to append the current prefix. In any direction, you'll probably have to implement a solution as I don't believe this is a native solution to your problem.
  13. I'm not a fan of hard-coding id's, obviously for this purpose it's fine, but for app building, I use the config var in case the page id ever changes (if a new version of PW is released and the admin id is now 3, your code won't break). echo '<a href="'.$pages->get($config->adminRootPageID)->url.'">this way to the admin</a>';
  14. Thanks guys! Nothing listed in cheatsheet for this variable. I thought about using $config->paths->root, however the site folder name is variable (as in the case of multi site), so I'm not sure how to find the variable name of the site folder to append to $config->paths->root. For example, my module wants a path to "site" for the default website and "site-website1" or "site-site2" or "site-whatever-i-name-this" in the case of multi-site. Maybe I have to use the config variable set in index-config.php, but I can't figure out how to access it. I know I can just use $config->paths->templates to get the site directory name, but it just seems to me that there ought to be something like what Teppo had mentioned... $config->paths->site.
  15. Tried that, and yeah, doesn't seem to exist for me (not in var_dump). I'm using the most recent production version of PW.
  16. Yes, does that exist? No mention of it in the docs. Thanks!
  17. Hi, I can't seem to find a variable that would point me to the site profile folder. Need to create path to: root/site/new_folder the vars that I'm aware of only point to folders within templates. e.g. root/site/assets root/site/modules root/site/templates etc., but I can't find one for... root/site root/site-two (in the case of core multi site) I know I can can simply remove the last part of the templates path, but there's got to be a cleaner way to do this, or Ryan did this intentionally to enforce the htaccess protection of php files inside the templates directory. (i probably just answered my question and will have to put my folder inside of templates)
  18. Fantastic, thank you both!
  19. Wouldn't this work for translating strings in the template file? <label for="myField"><?= __('Field Title') ?></label>
  20. Inline mode means ckeditor isn't loaded until a user clicks into the textarea. After doing so, the ckeditor toolbar is loaded and the textarea is changed to a rte. This is more efficient than say having 4 standard ckeditor RTEs on one page all loading at the same time.
  21. Thanks Pete, I didn't realize there was a field group already. Good points interrobang.
  22. This addresses the original post. I have built and operated a web shop that did $750 - $1mil in sales per year, so I have some experience in this field. You have categories, brands, and product attributes (like size, color, sex). What you don't want to do is mix these things up. Here's how I would approach this.... Categories -- Shoes ---- Heels ---- Tennis Shoes ---- Boots Your categories do not contain sex or brand, this is stored with the product. Here's what your product fields would look like... ProductTitle ProductCategoryPage (page field type) ProductManufacturerPage (page field type) ProductAttributesRepeater (repeater field type, there may also be a case for page field type. This is where you save things like color, size and sex, and probably sku depending on how your shop is set up) Then when you need to find products you have an efficient and flexible way to do so.... Find products in category boots where manufacturer equals brand $pages->find('category=boots,manufacturer=brandname') Find all products by brand then display by category $pages->find('manufacturer=brand') Find all products by color and sex $pages->find('attributes.color=orange,attributes.sex=women') Find all products by sex and category $pages->find('category=shoes,attributes.sex=men') I think it was mentioned, but I would also use url segments and a central controller to handle the page requests (a controller to build the product listing depending on values in the url segments). Just keep an eye your sql queries for performance. In some cases it may be better to use multiple smaller queries and filter the data in your loop. You may also need to use the autojoin feature on some of these fields, but I don't fully understand autojoin yet, so it may not do what I expect.
  23. I think benjaminE is saying a repeater with a limit on the number of items it can contain would work. In that case, what most people do (i'm not a fan), is allow for multiple repeater entries, however only display the first repeater item in your template. I agree, it would be nice to use a field group that would group fields together like a repeater, but w/o the option to add multiple items. If it worked the same way as repeaters, you could use the field in a field group and outside of a field group, but it's easy enough to create a new field.
  24. I know I can assign variables by using set or $config->var = something, but how do I set a configuration array? E.g. $config->site->theme
  • Create New...