Jump to content

Soma

Moderators
  • Posts

    6,808
  • Joined

  • Last visited

  • Days Won

    159

Everything posted by Soma

  1. - AWstats installed on most hosting servers is a server-side statistic "tool" for every visits and file accessed. - Google Event Tracking, make a click script that tracks events.
  2. I have upgraded and installed 2.3.8 many times and haven't had this error. Are you sure cache or cookies aren't involved?
  3. Soma

    soma|blog

    Thanks guys for all the great feedback. I've been adding some new stuff and working on many details. I updated my first post with what is used. I've also added a fix for the overflow issue in pre code boxes: white-space: pre-wrap; /* css-3 */ white-space: -moz-pre-wrap; /* Mozilla, since 1999 */ white-space: -pre-wrap; /* Opera 4-6 */ white-space: -o-pre-wrap; /* Opera 7 */ word-wrap: break-word; Thanks for those who decided to follow my blog already, so I just need to write something interesting. But that makes it more fun when you know people are watching.
  4. Soma

    soma|blog

    I added overflow: auto for the poor ones , jk Not sure what's better, but will let it for now.
  5. Soma

    soma|blog

    What Browser? This is handled by the Rainbow JS CSS with word-wrap: break-word; which will wrap long lines.
  6. Finally, replaced my old Site with a new Blog mostly about WebDev and ProcessWire. #processwire http://t.co/hUZHYLrdBT

  7. Soma

    soma|blog

    Thanks guys. @martijn, yes I added some more links @xeto, just added a RSS feed. Let me know if it works out for you.
  8. Soma

    soma|blog

    I just went ahead and did what I wanted to do since a long time. Yesterday at this time there was nothing. Now there's this: http://soma.urlich.ch/ My old portfolio, taking dust, is gone for good! Now I have new shiny blog. Starting with zero, this took a couple hours to setup a complete custom blog. I'm still working out details here and there and adding new stuff I still want to. But what I need and wanted is there now roughly. Some things used in this ProcessWire site: - ModulesManager (of course) - Hanna Code - Repeaters (for the inline code snippets added to content by some Hanna code) - Rainbow JS for the highlighting (http://craig.is/making/rainbows/) - PW Comments Core module - RSS Feed Core module - Markup Twitter Feed (http://modules.processwire.com/modules/markup-twitter-feed/) - Pocketgrid (there's no good grid system other than this http://arnaudleray.github.io/pocketgrid/) - FontAwesome Icon Font No frameworks used except PW. I hope I'll find time to write some things about web dev in general and ProcessWire. Hope you step by now and then.
  9. In some projects I use a mix of the $config->scripts and $config->styles FilenameArray to add scripts in templates. And one similar to the one Ryan, where I can create js and css files with the name of the template and they'll get loaded if existing. In a recent project I use a custom $config->siteScripts = new FilenameArray(); $config->siteStyles = new FilenameArray(); I set in a autoload module. Then I add the script in a template: $config->siteScripts->add($config->urls->templates . "js/yx.js"); This also allows for modules I create, for example widgets (that are not autoload), that need scripts/styles to add them with simply adding the method above in the init(). So as soon as I load the module in the front-end they'll get added to the array. To output, I use the same method as found in default.php from the admin template. <?php foreach($config->siteScripts->unique() as $file) echo "\n\t<script src='$file'></script>"; ?> You could also just use the $config->scripts used in the backend, but if you use form (InputfieldForm) API in the front-end, loading inputfields modules will also load scripts and styles from those in the filename array. This may not desired, that's why I use a custom filename array. For anything basic and global, I add scripts and styles hardcoded in the main template.
  10. There so many ways and use cases. I think with creating your own ProcessPageAdd module like Ryan mentioned would be a way to go, though depends on the case and you might need to maintain it in case the core one has changes that need to be implemented in your copy too. To use existing ProcessPageAdd you can hook into execute or buildForm. The latter being better as it returns the form not rendered so you can manipulate it. The ProcessPageAdd module also stores the template ($this->template) in case the Template family settings is set to only one specific, but this property is protected so you can't read it from outside the module. But you can add your own checks to get the parent and check for the family settings of its template. $template->childTemplates. Then use this info to check if it's your template you want to make changes. If you get this far you can also add fields to the form you wish to. These may even existing fields you are using on your page you create, and they will get saved along with the page add form. Just as an example to do what I said above: $this->addHookAfter('ProcessPageAdd::buildForm', $this, 'hookProcessPageAdd'); public function hookProcessPageAdd(HookEvent $event){ $process = $event->object; $form = $event->return; // get the parent page if(isset($_POST['parent_id'])) { $this->parent_id = (int) $_POST['parent_id']; } else { $this->parent_id = isset($_GET['parent_id']) ? (int) $_GET['parent_id'] : 1; } $this->parent = $this->pages->get($this->parent_id); // get the template via the child templates // if only 1 defined if(count($this->parent->template->childTemplates) == 1) { $childTemplates = $this->parent->template->childTemplates; $this->template = $this->templates->get(reset($childTemplates)); } if($this->template == "post"){ // load an existing field and get its inputfield to add to the form // this will be save to the page if the created page has the field $f = $this->fields->get("date_published"); $inputfield = $f->getInputfield(new Page(),null); // add the field after the page name field $form->insertAfter($inputfield, $form->get("_pw_page_name")); // populate page name field with a timestamp $form->get("_pw_page_name")->attr("value", time()); } } So far so good. The page title field is global and is also used on the page add process, it's also required, so you can't ignore it. It would be possible to remove the title field from your template. To do this you have to make the "title" field not global (field advanced settings). Once removed it will not get added to newly created template, and also you can remove it from any template. BUT there's some drawback, since the title is not global anymore, it will never be shown anymore in the page add process also for other normal pages! This gets kinda tricky. You could remove the title field and after that make it global again, but then it will get again shown at the page add process even if the template has no title field anymore. ProcessWire doesn't know. Also when opening the template you removed the title field previously, it is added again to the fieldgroup, and you can't remove it. See? So maybe best bet would be to leave it alone and just remove it from the add page form in the hook, or just populate it with some value, and later use hooks to concat values on page save to set the title dynamic. $form->remove($form->get("title")); So with all this in mind you could add "firstname", "lastname" fields to the add form with ease. Then use a Pages::added and/or Pages::saveReady to populate the title after adding the page. Or you could also "hide" the title field on the template. When editing the template, click on the title field to open context editor, select for visibility "Hidden, not shown in the editor". This will "remove" the title field on the edit screen. But you can still populate it via API if needed.
  11. Thanks for the report Joe. However it's not something I can reproduce. I can see how this would happen, but it shouldn't. if($page->template == 'admin') return; This is to prevent obfuscator to run in the admin at all, so it's not really possible that it happens to obfuscate emails in the admin. So hard to say why it happened on your side. But if it turns out to be a problem, we may look further.
  12. This would give you a pager without enabling PageNumbers on template, thus using /?page=2 instead of /page2 $pageNum = $input->get->page ? $input->get->page - 1 : 0; $limit = 5; $start = $pageNum * $limit; $result = $page->children("start=$start, limit=$limit"); echo $result->renderPager(); foreach($result as $p) echo "<p>$p->url</p>"; echo $result->renderPager();
  13. I'm using the _init.php as per the config.php. I'm not sure I understand why some things just don't seem to work in there. 1. I have a code to check for access on parents, though I can't get it to work in the _init.php $access_page = $page->parents("access_select_roles.count>0")->first; if($access_page->id){ // #29 if($access_page->access_select_roles->has("$user->roles")){ echo "access granted"; } else { $session->redirect("/login/"); } } It always throws notice: Notice: Trying to get property of non-object in /site/templates/_init.php on line 29 And I can't get it to work, as it looks like the page is found but can't check for properties. But when I add this code to a template file it works fine. Could this be due to some multiple calls of the _init.php, maybe when using $page->render() in some templates? 2. I'm trying to use the $config->scripts, $config->styles arrays and when I set them to be empty in the _init.php When I do $config->scripts->removeAll(); And add script from within template files, $config->scripts->add($config->urls->templates . "js/somescript.js") ... the filename array is just empty when I try to output them at the end in the output with <?php foreach($config->scripts->unique() as $file) echo "\n\t<script src='$file'></script>"; ?>
  14. Sorry @relmos, I have no solution and wonder why Ryan hasn't seen this yet. If you going the route with switching languages, there's also a way to make it by script if it's too many pages. Let us know so we can provide an example. Also considering other way, it would be possible to add another language "de" and ignore "default". But this would have the effect of still showing the default input for language fields. Also "default" has its purpose as when creating a page it is required to be filles, and as a fallback if no other language values are set.
  15. Yes there's wireCopy() wireCopy($sourcepath, $destinationpath, $recursive=true);
  16. I think you may have made an update at some point and merged the wire folder instead of replacing it. There were some changes to those that Ryan renamed and added new files.
  17. This has nothing to do with pw and is a native feature of form selects of your browser.
  18. Nobody? I don't have a testcase setup handy but I think you just need to stop home (id:1) from the entering the dropdown-toggle code, maybe: // first level items need additional attr if($item->numChildren(true) && count($item->parents) < 2 && !$item->id=1){ $title = $item->get("title|name"); $event->return = '<a href="#" class="dropdown-toggle" data-toggle="dropdown">' . $title . ' <b class="caret"></b></a>'; } ... I'm not sure I understand what you mean by the "and make it href link work just for that parent?" Yes you can. 'parent_class' => 'active', // string (default 'parent') overwrite class name for current parent levels
  19. How is re-saving a problem? set_time_limit(0);// in a template $books = $pages->find("template=book"); foreach ($books as $book) { $book->of(false); $book->save(array("quiet" => true)); echo "<p>Saved : $book->title</p>" } echo "<p>Done!</p>";
  20. No the syntax is right, just the logic is wrong and will never be both "false" it's a double or false trap. Just use PW way if (!$page->is("id=1001|1003")){ echo "block"; }
  21. Once pw gets to this code there is for sure a page name. To say differently a page requires a name actually to even exist. It's the only one required apart from id. So let us know what you want to do and somebody will tell.
  22. I'm not sure I fully understand what you expect or what this calculation is meant for on every load when editing a page, because when you change a value and save hte page, your calculated value is maybe still a wrong one. ProcessPageEdit is a perfect place to alter fields in context of a edit page in admin. But yes there's a Page::loaded. Edit: sorry for the edit, there's so many hooks and cases for what you can use them and where it makes sense or not. Often there's a lot of different ways to achieve the same, but not all maybe fit the case.
  23. And further ___buildForm recieves and returns a $form (InputfieldForm) object and not a page. So you have to do like: $form = $event->return; to get the form To get the page ProcessPageEdit is currently editing, you can use the getPage() method that you find in ProcessPageEdit #1128 $page = $event->object->getPage(); $event->object in the hook represents the module you hook into, that would be the ProcessPageEdit.module. Hope that makes sense and helps. And not it's not that trivial even for long time users.
  24. I think looks good except it should be addHookAfter. You add a new method with addHook.
  25. I finally tested the code again with multiple child pages and corrected what you mentioned, there was some logic error in there.
×
×
  • Create New...