Jump to content

Soma

Moderators
  • Posts

    6,808
  • Joined

  • Last visited

  • Days Won

    159

Everything posted by Soma

  1. You could try using the ImageSizer class of PW. $im = new ImageSizer($config->paths->root . "myimages/IMG_09.jpg"); $im->resize(100,0);
  2. Here a little helper module that does it optimized using direct SQL. https://gist.github.com/somatonic/5568201 If you install module you can do: $helper = $modules->get("RandomImages"); // load module somewhere before // getRandomImages(count, field, parent) $image = $helper->getRandomImages(1,"images", 1001); echo "<img src='{$image->size(150,0)->url}'>"; Or to get more than 1 $helper = $modules->get("RandomImages"); // load module somewhere before // getRandomImages(count, field, parent) $images = $helper->getRandomImages(2,"images", 1001); foreach ($images as $key => $image) { echo "<img src='{$image->size(150,0)->url}'>"; }
  3. I thought it would be the opposite... However this solution is slower than Wanzes.
  4. The forum shows an ajax overlay when someone else posts while you're writing..
  5. This is as simple as: $field = $modules->get("InputfieldSelect"); $field->attr("name", "myselect"); $field->addOption("myoption1", "My Option 1"); $field->addOption("myoption2", "My Option 2");
  6. @hani, not sure about your query. But it is possible to write a SQL query that does compare two fields on pages. I'm no SQL guru either but I've done this in the past but didn't post. Here a example with two joins comparing two date fields on page: $query = "SELECT id FROM pages p LEFT JOIN field_mydate m1 ON p.id = m1.pages_id LEFT JOIN field_mydate2 m2 ON p.id = m2.pages_id WHERE m1.data > m2.data AND p.status < 2048"; $res = $db->query($query); $ids = array(); while($r = $res->fetch_array()) $ids[] = $r['id']; // fetch the ids $pa = $pages->getById($ids); // get pages foreach($pa as $p){ echo "<p>$p->title - $p->mydate - $p->mydate2</p>"; }
  7. This process is used in Wysiwyg to select and resize the image. The error indicates that it didn't find the image object and thus have no height() method as it would have. Strange here is the the previous line does seem to work.
  8. Template cache, caches the page as it's being sent to the browser, same as if you would save the page in the browser to static html, not matter what and how many includes you have to render the page.
  9. If the parent page is hidden you'd have to include "include=hidden" in the selector when doing a find(), but not if you get() the page explicitly. Also wanted to note that doing $pages->get("title=previous caption winners")->children; isn't a very reliable method to find a page by it's title, since the title isn't unique. In most cases it makes more sense to use id or page name, page path. $pages->get(1005)->children; Or maybe $pages->get("/some/path/")->children; To find if a parent has children there's also a method in PW numChildren(). if($pages->get(1004)->numChildren) { // has children } In PW 2.3 there's a new version of numChildren() to make it access aware if you pass true as the argmument if($pages->get(1004)->numChildren(true)) { // has children that are really visible to the user }
  10. $cat = $sanitizer->selectorValue($page->title); // works $p = $pages->find("portfolio_categories*=$cat, template=portfolio, sort=-Project_Date"); This doesn't work because a page field doesn't work with operators and titles... as teppo explained. So you could imageine this: portfolio_categories*=mycategory could be seen same as: 1003|1004|1005*="mycategory" So you would need to give it a page id or a page array and PW will make the rest. portfolio_categories=$somecategorypage If you do echo $somecategorypage, the toString() method of page will output the id... So it would be like this now: 1003|1004|1005=1004 Or if you use a page array. echo $pageArray it will return a 1003|1004|1005 string which is usable also in a selector. 1003|1004|1005=1003|1004|1005
  11. You can move a page into another parent, but that parent has to be open.
  12. Works fine in repeaters for language fields. Any more infos to help reproduce this?
  13. What is this number for the category you'r importing? In PW a category would be best handled as a page, so it could be the ID of that page. Then you make references using the page field. Common scenario is to import/create categories first then use their id's to import data.
  14. I use Sublime Text.
  15. Can't tell a problem without understanding exactly what you're doing on "other pages". If you reference a page it will always have the actual data from that page, unless you have a cache on these pages.
  16. A page field always saves the page id of the selected page, there's no way to save another value. After all it's just a relation with from page id to page id.
  17. Maybe adding something like that would benefit to allow adding scripts and styles before all admin ones. Of course admin templates would have to implement it aswell as long as it's "hardcoded" in admin template. Which in the long run makes it hard to change those parts and every iteration (already were a couple in admin templates) all admin templates suffer from missing something. I could even see go as far as modularize the output so there would be a core module that would be hookable to add scripts and styles more precisely. Just thinking loud.
  18. No I don't know of a better solution. But I don't really see a problem much as the script and styles gets added after the admin main.css... One other solution would be to add an additional script and styles foreach to the admin default.php after the ones already there. <?php foreach($config->cpScripts->unique() as $file) echo "\n\t<script type='text/javascript' src='$file'></script>"; ?> And load scripts and styles to a new config array: $this->config->cpStyles = new FilenameArray; $this->config->cpScripts = new FilenameArray; Then add scripts and styles to that. This way you could also add styles and script even from within the template too.
  19. Sorry but I can't reproduce this. Image are always rendered the same order as in the admin. It's not possible to add another text field unless you modify the module (make a copy to site folder and rename all relevant names and add more text fields) or use ImagesManager where you can have as much custom fields a page can hold.
  20. Maybe in this case nothing to worry about, but I find the Process modules a great thing also because it's a actual Class you can create execute functions and hook into them or load stuff from one module to another. Now there's only one ProcessModuleAdminPages and one execute.
  21. Those where the times on a wide screen. #sentimental http://t.co/i2Na03jhCh

  22. Ah you get that error on front-end! Yeah then it's because you overwrite $config->scripts. Yeah the module does also get init'd on front-end as all autoload module does, but the hooks also get executed. I just updated the module now to not add the hooks when on front-end.
  23. What if you want to hook a admin page like this or use $this->process to identify what admin page you're on?
  24. According to your error this code fails $this->config->scripts->add($this->config->urls->AdminHotKeys . "jquery.hotkeys.js?v={$version}"); Strange ad it makes absolutely no sense. There's nothing wrong here and it's a common code used in many places in ProcessWire and I have no idea why it would fail there. I tested to make sure it works in all PW versions. The error says that $this->config->scripts isn't an object, but then PW admin wouldn't work at all, and I see no indication AdminHotKeys screws that up. What PW version do you have installed and what PHP version, any other 3party modules? Even if a module is uninstalled it will get parsed by php and any error will show. If you want to get rid of a module you ahve to remove it completely.
  25. Where is the censor filter when you need him.
×
×
  • Create New...