-
Posts
6,798 -
Joined
-
Last visited
-
Days Won
158
Everything posted by Soma
-
Enable debug mode for only superusers or a given username
Soma replied to lpa's topic in General Support
All you can do in the site/config.php is something like you can get from PHP: $config->debug = false; if(isset($_GET['debug'])) $config->debug = true; So you could add /?debug to a url and have debug mode on. Or you could add this to the top in admin.php template in site/templates/ folder if($user->name == 'admin') $config->debug = true; And have debug mode only for admin only in admin. -
Enable debug mode for only superusers or a given username
Soma replied to lpa's topic in General Support
It's not possible or doesn't do anything in a template because PW needs the config to be loaded at the very start, and at the time a template is rendered it's maybe already too late. Also it won't enable it in the backend, which you probably want. Why not directly in the config.php.? Well, you also can't use $user in the config.php itself, since it's too early and $user isn't yet there when loaded by PW index.php. So the best option (if I'm not missing something) would be a autoload module and put that code in the init function. public function init() { if($this->user->hasRole('superuser')){ $this->config->debug = maybe; } else { $this->config->debug = false; } } If you put that in HelloWorld.module's init it will work fine and load at the beginning when the API becomes available. Edit: somewhere along these lines if not completely mistaken. -
Just $pageArray-> has("id=1001|1003") will do it.
-
Welcome! Im sure youll get millions of answers within shortly. (Love it)
-
Aaaand you also need to enable Page Number setting on the template you use this code.
-
There's an example on that page you linked... Let's look, to have PW pagination module work you need to use some search $pages->find() ..children() ..siblings() with a limit selector as explained above. But this alone isn't going to cut it. You'll also need to render the pager. This, you do by using the result you get from the find() and add a renderPager() to it. So the above code is missing that. Let's add the missing part. <?php if($page->numChildren) { $result = $page->children("limit=2"); // render the pager echo $result->renderPager(); // render the children echo "<ul class='nav'>"; foreach($result as $child) { echo "<li><a href='{$child->url}'>{$child->title}</a></li>"; } echo "</ul>"; // render pager again? ok echo $result->renderPager(); } Wasn't that easy?
-
Problem with language-alternate fields in repeater
Soma replied to Fokke's topic in Multi-Language Support
Yeah its an input(field). Sorry to confuz you. ;-) Theres even an FieldtypePageName and InputfieldPageName. (A db field isnt also a field?) -
Problem with language-alternate fields in repeater
Soma replied to Fokke's topic in Multi-Language Support
Only mandatory field is name. Title can be removed. Hint globall settings. -
I have this installed recently on a latest PW, and it doesn't do anything after saving. Also the remember setting doesn't do remember. Any ideas?
-
It's "not possible". http://processwire.com/talk/topic/651-set-created-by-creating-a-page-via-api/ Some technique would be to import to a date field you add to templates and use that, or copy that date later via SQL to the pages table 'created' field.
-
The fix would be easy to add this before line #62 if(!$this->input->get('id')) return;
-
Ah sorry missed the change temple part... now it's more obvious a bug
-
Nothing wrong there, this is bitwise operator http://www.php.net/manual/en/language.operators.bitwise.php Ther error says $this->editedPage is not an object... so maybe even the line before fails for you for unknown reasons $this->editedPage = wire('pages')->get((int)$this->input->get('id')); can you try replace #62 with echo wire('pages')->get((int)$this->input->get('id')); exit; And refresh page and see what output?
-
Works just like a charm here.
-
http://processwire.com/about/news/introducing-processwire-2.3/#newfunctions Some of those link to the repository are broken, since you changed the class file names.
-
You could try using the ImageSizer class of PW. $im = new ImageSizer($config->paths->root . "myimages/IMG_09.jpg"); $im->resize(100,0);
-
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}'>"; }
-
I thought it would be the opposite... However this solution is slower than Wanzes.
-
The forum shows an ajax overlay when someone else posts while you're writing..
-
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");
-
@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>"; }
-
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.
-
Caching include files called by template files
Soma replied to Peter Falkenberg Brown's topic in Getting Started
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. -
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 }
-
$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