Leaderboard
Popular Content
Showing content with the highest reputation on 04/05/2016 in all areas
-
Nothing is impossible. This is quite easy with MarkupSimpleNavigation: $tree = $modules->MarkupSimpleNavigation; $treeOptions = array( "show_root" => true, "outer_tpl" => "<ul class='main-menu cf'>||</ul>", "inner_tpl" => "<ul class='sub-menu'>||</ul>", ); $tree->addHookAfter("getItemString", null, function ($event){ $child = $event->arguments("page"); if($child->id != 1 && $child->numChildren(true)){ $itemStr = "<a href='{$child->url}'>{$child->title} <span class='drop-icon'>▼</span> <label title='Toggle Drop-down' class='drop-icon' for='tab_{$child->name}' onclick>▼</label> </a><input type='checkbox' id='tab_{$child->name}'>"; $event->return = $itemStr; } }); $menuStr = $tree->render($treeOptions); <nav id="mainMenu"> <label for='tm' id='toggle-menu' onclick>Navigation <span class='drop-icon'>▼</span></label> <input id='tm' type='checkbox'> <?php echo $menuStr;?> </nav>6 points
-
Sure enough, after posting I found this: https://processwire.com/talk/topic/10562-general-question-is-there-a-difference-between-adding-prependappend-file-to-template-and-include/. Using the 'include' in the template php file solved the issues. Now I'll just crawl back into my newbie hole.3 points
-
$pages->getPageFinder()->find(new Selectors($selector), array('returnQuery' => true))->getQuery(); I seem to recall teppo posting a less verbose version of this, but I cannot find it currently.3 points
-
Make sure you have dbHost configured as 127.0.0.1, not as localhost.2 points
-
The heredoc syntax behaves exactly like double-quote strings in a single line. Both do not support calling a function in it, only class methods or anonymous functions, see here for examples: http://stackoverflow.com/questions/10002652/in-php-how-to-call-function-in-string Edit: What might work is this, as templates while mostly using local variables are still executed in class context. $a = <<<EOT My {$this->_x('text', 'noun')} EOT; Edit2: You're also using nowdoc instead of heredoc, which does not allow for variable substitution at all, like single-quote strings. See here: http://php.net/manual/de/language.types.string.php#language.types.string.syntax.heredoc2 points
-
2 points
-
There exist a lot of htaccess rules for that. Example: Header set X-Frame-Options DENY Header always append X-Frame-Options SAMEORIGIN https://developer.mozilla.org/en-US/docs/Web/HTTP/X-Frame-Options2 points
-
Hi, it is pretty much impossible to 100% secure it since most stuff can be (easily) spoofed. If the content is publicly accessible it's possible to access it. That's the baseline rule of internet content security. You can of course build some barriers to make it harder. There are several options to throw up some barriers: JavaScript checking the parent hostname (this can be spoofed) Mess around with the referer stuff in .htaccess (can be spoofed too) Check how ProcessWire denies its access to other iframe My opinion: you can throw as many barriers as you like, but especially the people who want access are the people to know and overthrow the barriers you build. Do2 points
-
hello! I created a new site for my podcast Machines-ethics.net and thought I should create a version for anyone to use. With PW-podcast profile you can create one or more lists of pages with content and create one or more itunes RSS feeds to syndicate your podcast (as well as listening online). There is also a blog section and basic pages for anyother page you need. Check out the example site here: http://pw-podcast.nicegrp.com/ and the github here: https://github.com/benbyford/pw-podcast1 point
-
Have a look at this diagram https://processwire.com/talk/topic/12933-getting-field-name-in-the-loop/?p=117417 // this returns an object; either a Page object or PageArray object // depending on whether p_contact is a single or multiple page field (@see diagram in post I linked to) $contactId = $page->p_contact; // toString() method will return this object's ID (1234) or IDs if multiple page field (1234|3456|6889) echo $contactId; // no need for this. You already have an object $contact = $pages->get($contactId); echo $contact->title; // if p_contact is a single page field echo $page->p_contact->title; // OR $contact = $page->p_contact echo $contact->title; echo $contact->parent->title echo $contact->id; // echo whatever property // if p_contact is a multiple page field (i.e. returns a PageArray) foreach($page->p_contact as $c) echo $c->title; // OR foreach($page->p_contact as $c) echo $c->parent->title; // OR $contacts = $page->p_contact; foreach($contacts as $contact) echo $contact->title; // OR echo $contacts->first()->title; // OR echo $contacts->eq(3)->name; Good practice to always check if your page field returns something (i.e. that it is not empty) before outputting from it // single page field if($page->p_contact)// do stuff // OR if($page->p_contact && $page->p_contact->id > 0)// do stuff // OR for multiple page field if(count($page->p_contact))// do stuff1 point
-
Or you create a class for the job. Edit: Also are you sure the first example of your entry post does work? As nowdocs do not substitute variables it shouldn't. If it's not working please correct your entry post.1 point
-
By default you cannot frame a page running under PW from other domain, because X-Frame-Options is set to SAMEORIGIN In your case you could change the directive to X-Frame-Options ALLOW FROM {uri} Unfortunately this is not supported in all browsers (Chrome?). You have to try out. Maybe best solution is to move to a host which supports PHP and PW of course.1 point
-
To start with, with DigitalOcean you can choose the location of your droplet, or spread your droplets across the world. You can activate / provision / switch off droplets via API. You pay by time and not by month, so if you need more resources at peaks, you just activate more. It's for different usage. HE is for "hosting", DO is for a scaling infrastructure that can be programmatically coordinated. docker-machine supports Digital Ocean, but not Host Europe. Besides, with DO you have a lot of choice between various OS and pre-configured systems, for example for tryout. And it comes without plesk, which to me is an advantage For you, HE is probably the best option. For others, it's something else1 point
-
Don't use SessionHandlerDB module. Or uncheck "Track IP addresses in session data". Check what you get from $session->getIP(true). It might be related to IPv6 (https://github.com/ryancramerdesign/ProcessWire/issues/1596).1 point
-
Thank you all for your help on this one. @szabesz I would rather not like to install Trasy Debugger if there was a simpler method through the API @LostKobrakai the suggested code returned null. But this version (with parentheses appended to the getQuery method) works: wire('pages')->getPageFinder()->find(new Selectors($selector), array('returnQuery' => true))->getQuery(); It returned exactly the query I was looking for SQL_CALC_FOUND_ROWS pages.id,pages.parent_id,pages.templates_id FROM `pages` JOIN field_id_gc AS field_id_gc ON field_id_gc.pages_id=pages.id AND (((field_id_gc.data='16800' ) )) JOIN field_timestamp AS field_timestamp ON field_timestamp.pages_id=pages.id AND (((field_timestamp.data>='2016-01-28 15:00:42' ) )) JOIN field_timestamp AS field_timestamp1 ON field_timestamp1.pages_id=pages.id AND (((field_timestamp1.data<='2016-02-16 00:19:53' ) )) LEFT JOIN field_timestamp AS _sort_timestamp ON _sort_timestamp.pages_id=pages.id WHERE (pages.templates_id=44) AND (pages.status<1024) GROUP BY pages.id ORDER BY _sort_timestamp.data LIMIT 0,100 @kongondo $queries = $database->getQueryLog(); returns an array of queries with a lot more info than LostKobrakai's code and the specific query is not included. The querie here look somewhat like the output of Debog Mode Tools in backend.1 point
-
Dumbfounded by this one. Are you able to start over (i.e. a fresh install)? Otherwise this really is a FieldtypeComments question (a core module) since that's what Blog uses.1 point
-
For Chinese characters, I just copied the characters I needed to use in a page name and appended them to my $config->pageNameWhitelist, like this: $config->pageNameCharset = 'UTF8'; $config->pageNameWhitelist = '-_.abcdefghijklmnopqrstuvwxyz0123456789' . 'æåäßöüđжхцчшщюяàáâèéëêěìíïîõòóôøùúûůñçčćďĺľńňŕřšťýžабвгдеёзийкл' . 'мнопрстуфыэęąśłżź健康長壽·繁榮昌盛'; You'll have to make sure that your /site/config.php file is UTF-8 encoded, which it should be by default. But depending on what editor you are using, it's always possible it's not.1 point
-
Try getQueryLog(); (with $config->debug to true) https://processwire.com/talk/topic/11483-duplication-in-query-results/?p=1069941 point
-
Hi, How about Tracy Debugger's "Debug Mode" panel? There aren't too many queries listed for an almost empty frontend page.1 point
-
Another way could be: When automatically creating the userpage in your hook, you can set wire('page')->created_users_id = wire('user')->id Now the page is owned by that user. When the user logs in to lets say .../userpages, in the template.php for userpages you can get the user's page with $pages->get("template=userpagetemplate, created_users_id={$user->id}") To be able to change the user of a page, you need to enable this in the template settings for the userpage-template in the Advanced tab towards the bottom.1 point
-
I would look at using the WireCache functionality. You can find more about that here: https://processwire.com/blog/posts/processwire-core-updates-2.5.28/1 point
-
Hi 101Bram, Welcome to ProcessWire! So you somehow need to link one election page to one user account. Check out the Page field. On your user template, you can create a new Page field, let's name it "election". After creating the user and the corresponding election page, you can store the election page in this field. To create a link, you can simply use: $electionPage->url. Note that on your election template, you should check if the visiting user is equal to the user where the election page belongs to. If not, you can throw a 404 error. As always with ProcessWire, this is just one way of doing it Cheers1 point
-
Looks as if you have an entity encoded ampersand in there - terminio.at//en/social-login/?hybridauth=login&hauth.done=Google <edit> and a double slash (.at//en) </edit>1 point
-
Following up on my post above...Say you wanted to embed a YouTube video...for whatever reason...in the page edit context.. <iframe width="420" height="315" src="https://www.youtube.com/embed/Bohhf3aK8gU" frameborder="0" allowfullscreen> </iframe> That's it!1 point
-
1 point
-
1 point
-
Use getQueryLog() Maybe something like: $queries = $database->getQueryLog(); foreach($queries as $query){ if (strpos($query, 'classification')) {//just to limit our search since there could be other queries echo '<pre>' . $query . '</pre>'; } }1 point
-
<silliness>I've been meaning to do a video demo of a list of silly thinks/pranks you can do with RunTimeMarkup...you know, a countdown to lunch break, a thing that shouts "peekaboo" every time you type a certain letter on your keyboard, a (not-so-silly) live spell-checker, etc....But then again, I have been meaning a lot of things... </silliness>1 point
-
I had been so tempted to post about the logo a few days ago! But seemed so silly to do it. Though I find it very amusing that minimal details in both logos make them quite different in the end. Too bad they got hacked, I follow a few artists that get support there. One of my favourites.1 point
-
In my case i only have 1 field and then my code checks for which template it's on, then outputs various buttons and messages; the buttons themselves just link to templates that read the url parameters and run some process. Eventually i'll probably have a generic module to process the buttons.. i think I'm going to be using this a lot!1 point
-
1 point
-
Pushed a small update, which removes path-details when access rights are not available, as it would falsely suggest that only under this path a role would have no access. Also added a bit of a description about how templates are distributed over the tabs. Also made the module officially 2.6 compatible.1 point
-
I think you're looking for something that isn't really there the way you maybe think. To my mind comes, that you could simply create a custom admin page and just output a markup table that list's all unpublished pages. There must be some thread about it with more examples how to create custom cp admin pages. Example: Create a new page under the Admin tree. Select the "admin" template and give it a title. After saving and publishing it will appear in the top navigation. If you go to the newly created admin page it will output "This page has no Process assigned." You then need to create a new Process Module. That Process Module would basicly look like this: (this is a quickly stripped example from a module I did a while ago) <?php /* * ProcessWire Module * Simple Example admin page Process module to output unpublished pages * * Put this module into you /site/modules folder * Create new admin page using "admin" template and assign this Process module * */ class ProcessUnpublishedList extends Process { protected $sel_unpublished = 'sort=-modified, status=unpublished'; public static function getModuleInfo() { return array( 'title' => 'Process Unpublished List', 'summary' => 'Show unpublished pages in the admin', 'version' => 100, 'permission' => 'page-edit' // or any other permission to manage access to this admin page ); } public function ___execute() { $out = ''; $fieldset = $this->modules->get("InputfieldFieldset"); $field = $this->modules->get("InputfieldMarkup"); $field->label = "Unpublished Pages"; $field->collapsed = Inputfield::collapsedNo; $table = $this->modules->get('MarkupAdminDataTable'); $table->setSortable(false); $table->setEncodeEntities(false); $header = array('Title','Status','modified','by user'); $table->headerRow($header); $rows = array(); $pageArr = $this->pages->find($this->sel_unpublished); foreach($pageArr as $p){ $status = ''; $status = $p->is(Page::statusUnpublished) ? "unpublished" : ''; $editUrl = "{$this->config->urls->admin}page/edit/?id={$p->id}"; $rows[] = $p->editable() ? "<a href='{$editUrl}' style='opacity:0.7'><s>".$p->get('title|name|id').'</s></a>' : $p->get('title|name|id'); $rows[] = $status; $rows[] = date('Y.m.d H:i:s',$p->modified); $rows[] = $p->modifiedUser->name; $table->row($rows); $rows = null; } $field->value = $table->render(); $fieldset->add($field); $out .= $fieldset->render(); return $out; } /** * example * accessing /processwire/adminpage_with_this_module/list2/ * will map to this function */ public function ___executeList2(){ $out = "List2"; return $out; } } Edit: This example shows that you can use certain processwire modules to create fieldsets or a MarkupAdminDataTable to generate markup. This is how PW itself does build all the admin pages pretty much. But you can also just create your own simple html markup and output that.1 point