Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 05/27/2016 in all areas

  1. This week our focus was on the server side of things rather than on the code side. Sometimes you've got to open the hood and change the oil in order to keep things running smoothly. But rather than just changing the oil, we opted to replace the entire car, moving from our compact family sedan to a turbocharged supercar, so to speak. Basically, we've had some major server upgrades this week! This post covers them in detail: https://processwire.com/blog/posts/web-hosting-changes-and-server-upgrades/
    7 points
  2. Where does the $title variable come from in your code? You don't show where it is set. To set the URL you want to set the name of your page. $np->name = 'something'; If you don't set a name (as in your code) the name is generated automatically from the title. If you are setting a name from a variable you can pass it through $sanitizer->name($my_variable) to make sure it is a valid name. In your case you want to set the name to the same as the page ID. But when you are first creating your page the ID doesn't exist until you save it. So you can do something like this: $np = new Page(); // create new page object $np->template = $templates->get("lost-property"); $np->parent = $pages->get("/lost-property/"); $np->title = 'my title'; $np->save(); // save the page so you can get its ID $np->name = $np->id; // set your other page fields $np->save();
    5 points
  3. AdminOnSteroids Various admin tweaks to enhance ProcessWire admin. http://modules.processwire.com/modules/admin-on-steroids/ https://github.com/rolandtoth/AdminOnSteroids
    4 points
  4. Movie time! These are two tweaks: always visible sidebar items and fixed header/sidebar. There are still some details to polish but seems useful.
    4 points
  5. @Robin S Thanks for pointing this out. This note is obsolete. I missed to remove it from earlier versions. The cronjob is triggered by every user.
    4 points
  6. I'd recommend using prepared statements. ProcessWire's database class extends mysqli, so you can do: $statement = $this->database->prepare('INSERT INTO tablename (Comments) VALUES (?)'); $result = $statement->execute(array($comment)); (This is written off the top of my head, not tested)
    3 points
  7. For reference, you can also make sure this happens when a page is saved in the admin as well. <?php class AdminHelperHooks extends WireData implements Module { public static function getModuleInfo() { return array( 'title' => 'Admin Helper Hooks', 'version' => 1, 'singular' => true, 'autoload' => true ); } public function init() { $this->addHookAfter('Pages::saveReady', $this, 'hookChangeNameToID'); } public function hookChangeNameToID(HookEvent $event){ $page = $event->arguments(0); // get the page being saved if ($page->template == 'lost-property'){ // check the template $page->name = $page->id; } } }
    3 points
  8. Maybe you have an autoload module or an init file somewhere that puts the output formatting off.
    3 points
  9. To make a site with ProcessWire you will have to do work a bit more than that. The documentation is there, and it's very complete, but it won't teach you sokething that specific. You will have to join the pieces of the puzzle yourself. It's totally worth it though, once you learned by yourself how to list your articles with the thumbnails, you wil know how to do anything you want. And I mean anything! No code examples as I'm on mobile, sorry.
    3 points
  10. I've personally never been a fan of VPS hosting outside of AWS or Google. That said, I've moving an ocean of servers and sites into AWS including running on Bitnami. Most of the bitnami AMIs are free to use on AWS so all you do is pay for use of the instance and attached storage so you can make it as big or small (even free) as you want. I've personally found the setup of Bitnami instances confusing and prefer to do this myself but I also work in this space so I'm not exactly an average user.
    3 points
  11. v006 is up - there are some new Reno theme tweaks plus LoadCollapsedModuleInfos. This auto-collapses module info fields on module configuration pages, saving space.
    2 points
  12. @joer80, You should be able to use the PDO prepare(), bind() and execute() methods. Here's a short example; $statement = wire()->database->prepare("INSERT INTO `tablename` (`comments`) VALUES (:comment)"); $statement->bindParam(":comment", "The boat is 17' long. "); // Defaults to binding as a string. $statement->execute();
    2 points
  13. @horst — you're boss
    2 points
  14. @alan: I just updated the readme: https://github.com/horst-n/WireMailSmtp
    2 points
  15. wunderbar! gut -> besser -> tpr
    2 points
  16. v003 is uploaded with some "before-the-weekend" Reno theme updates: Make header sticky: stick the header to the top of the browser window so it stays in place when scrolling down Make sidebar sticky: stick the sidebar to the top to make it always visible Auto hide sidebar on left: auto hide the sidebar so it's accessible by moving the mouse to the left side of the screen Always show sidebar items (disable accordion): make sidebar submenus more compact and do not hide them Place header button next to the main title: moves the top (cloned) main button next to the title to make it easier to reach Move notice close buttons to the left: put the close button of the notice message to the left for easier access
    2 points
  17. @suntrop: This is how I add a Twig Extension (in my case the Intl Extension, but this shouldn't matter): add Twig Extensions via composer { "require": { "twig/extensions": "~1.3" } } add Hook after initTwig() (as Wanze said) $this->addHookAfter('TemplateEngineTwig::initTwig', $this, 'addTranslationFunctions'); add Twig Extension public function addTranslationFunctions(HookEvent $event) { $this->twig = $event->arguments(0); if (!class_exists('Twig_Extensions_Extension_Intl')) { require(wire('config')->paths->TemplateTwigReplaceLanguageSupport . 'vendor/autoload.php'); } $this->twig->addExtension(new Twig_Extensions_Extension_Intl()); } --- To check for a multidimensional array, you could try: {% if input.post is not empty and 'name' in input.post|keys %}
    2 points
  18. Welcome to PW and the forums @JeevanisM The link @Joss pointed you to has exactly what you want...i.e., creating thumbnail grab for pages..see under 'Resizing Images'... foreach($page->images as $image) { $large = $image->width(500); $thumb = $image->size(100, 100); echo "<a href='$large->url'><img src='$thumb->url'></a>"; } Whilst there's still need for better documentation, we certainly don't lack documentation about the basics...the stuff that will get you up and running with ProcessWire...I know it can be confusing at first but ProcessWire is really easy... A bit OT but as a beginner, I personally wouldn't install ProcessWire with a site profile unless I have first read up on how the different site profiles work (tutorials section in the docs). Why am I saying this? Because they contain some functions that really have nothing to do with ProcessWire but are helper functions created to suit those profiles that may confuse you (especially if you don't know what's coming from where). For instance, the renderNav() function you've pointed to. That is not part of ProcessWire but just a helper function created in those profiles. Instead, I would install ProcessWire without a site profile (aka the blank profile), create a blank template file in my favourite text editor and on my second monitor (if you have one ) open the ProcessWire docs about $page and $pages and start playing. Just plain PHP...no CSS and JS . Once I got the basics is when I'd start thinking about displaying cute DIVs . Sorry if I sound brash...just typing in a hurry...+ above is my personal opinion...'horses for courses'...they say..And if you've already gone through the docs, apologies...ignore me... Whatever your learning style, I hope you stay with ProcessWire. I promise you the benefits (once you get over the initial hurdle) far outweigh the initial pain of adjusting to a new system, especially one in which you have to type a bit of code PS; Don't let my post put you off from asking questions, mind...
    2 points
  19. Okay, please let us know what you have tried and maybe someone can help you resolve your issue. The forum members are eager to help, you just need to provide some detailed information about what it is that you want to achieve. You would be surprised how much can get done, when we all work together.
    2 points
  20. Words of encouragement from the Pub's amateur psychiatrist (Read best in a soft spoken, German accent) Ah, you are here because you have been reading things in this forum about pages that have left you confused, disorientated, befuddled. You thought you knew what a page was - you have been thumbing through them, folding them, studying them, wrapping things up in them and scrolling up and down them for most of your life! A page is this solid item - this great lump of data stuffed with things. But now you have come to Processwire, and everything you thought was true, simply isn't any more. For in Processwire pages are completely different - they are not great gulps of information, but tiny little things, nothing more than a link to the more interesting world of fields and templates; just a little blip of data in your huge fascinating database. Pages in Processwire are used for all kinds of things. They can be used as a marker in your pages list. They can be used as a group parent for other pages. They can be used as categories, tags or lists or users. And they can even be used for simple drop-down selects - just to supply a label and value. It can seem crazy to use such an iconic thing like a page for such a mundane and trivial task! But don't worry and fret, don't lose sleep or pace the floor as you think the reputation of the noble page is being crushed! In Processwire, they are fulfilling their duty to the full - and the more slight the task, the more they bound up to the wall and jump up and down shouting "use me, use me!" And, as a bonus, they can even be used for content - for all that stuff you thought was a page, but in Processwire isn't! So, don't be put off by the Processwire page - use it for everything! it is much smaller than you think, takes up hardly any space at all, is well behaved and only will do its thing when it is called. In fact it is hardly a page at all .... and then again, it is also so much more!! Better now? Joss Freud
    1 point
  21. Do you set $user->language somewhere in your code? Maybe we could help more seeing your template code.
    1 point
  22. Check the latest commit (v004). There are other fixes as well for the admin themes, eg. do not apply some changes to modal contents, plus only add body classes to the proper admin themes. This would be surely possible but I need some time to fully understand it At first I'll concentrate on the "basics".
    1 point
  23. don't know how your module is organized (deadline coming), but throwing in an idea: maybe we could have a "custom" folder, where we can put in our own code snippets and your module will make them visible for toggling on/off. for example: /custom/makeButtonsBigger.js would result in some custom code that makes admin buttons bigger and a checkbox in your module. that way we could build our own repository of admin tweaks, put them on github or the like and on every new pw-install we would just have to do a git clone and tick some checkboxes. what do you think? this is quite similar to admincustomfiles but i never found it really easy to use so i don't really use it a lot. maybe we could have some kind of syntax in thos files to restrict it to a selector and show some better descriptions in your module/panel /* custom admin tweak example * * #summary * this is a great summary * with lots of content * * #pageselector * id>10 * * #editedpageselector * template=example */ $(document).ready(...); #editedpageselector would refer to the currently edited page in processpageedit, whereas #pageselector would refer to the current admin page any thoughts on this?
    1 point
  24. Didn't try the module (great name btw) yet, but how about making header sticky in the default admin theme? after-the-weekend, of course
    1 point
  25. The reason you would have to look for is why the homepage has output formatting turned off, because it's not usual at all. Output formatting is always turned on in front-end templates.
    1 point
  26. I would prefer these extra buttons always visible. Waiting for the hover will cause frustration sooner or later Perhaps adding them below the main button?
    1 point
  27. Thanks soo much! Can't wait to try it out. Unfortunately I have to deal with a deadline, but I will manage to try it out on the weekend, I'm sure.
    1 point
  28. I am guessing that what Ivan is after is a Menu Builder MSN combo....as per the conversation we had....starting from here...and culminating with a PageArray here..If there was a possibility to do an in-memory $page->child = myOtherPage...(without saving)...hence assign non-native/natural children to parent menu items....that would probably solve his problem (the multidimensional bit) ...but that is not possible, If it were, don't know if getting in-memory children would work though...
    1 point
  29. I'd really like to see a PageTree object, which can hold a (whole or partial) page tree in memory. This would allow for testing stubs and similar or the api creation of a whole tree branch at once. But sadly the PageFinder class is often dependent on mysql functionality, which by now does not have feature parity with the in memory selector engine. Also a page tree object is not really like a multidimensional array, but rather a array of pages, which optionally hold another array of children. The concept this is more like e.g. the pw form api does work with it's fieldgroups. I could imagine something like this: class Tree extends WireArray{ public function isValidItem($item) { return $item instanceof Branch; } […] } class Branch extends Wire{ protected $page; /** @var Tree $children */ protected $children; function hasChildren(){}; function getChildren(){}; function addChild(){}; […] } Edit: Really nice could also be a base Tree class, which both a PageTree as well as e.g. the Forms API could inherit from. This would also allow for easy implementation of other (custom?) tree based constructs. Nested comments for example just came to my mind.
    1 point
  30. I have a question regarding the condition: Is there some way around this? I don't want to give any other roles this permission besides superuser (and the only superuser is me) because I don't want to give site editors the ability to restore backups. But I also don't want to have to be regularly browsing the website myself just to ensure the backup cron job runs. You mention running the backup from a standard cron job above - how does the db-backup permission come into play here?
    1 point
  31. Giving admin theme corrections a second thought I support the idea. I have a few other fixes in my mind besides your suggestions so stay tuned.
    1 point
  32. On pages like the older images doc, there are links at the bottom (RELATED FORUMS THREADS) in the form of: .../index.php/topic,97.0.html Don't know if those were working before the switch, but now they don't. Also I know that we have the brand new Docs, what are very fast growing! Just wanted to mention.
    1 point
  33. I wonder why nobody/Ryan answers here.... No it's not possible. I also ran into it. InputfieldCKEditor.module does configure purifier hardcoded with the allowing the target _blank. Nothing else. But the thing is we can configure the Link Editor to use different targets. But when adding a new one like "_parent", it won't allow it as it's hardcoded. In my opinion the InputfieldCKEditor.module should recognize the target config of Link Editor and add those to the allowed targets.
    1 point
  34. Not sure if the bug tracker is better for this or not, but I've definitely found a bug in the Image field when using SVG files. SVGs upload without error and display thumbnails, but they have no trashcan icon and are deleted when the page editor is reopened. Existing files uploaded with the old version of image are not deleted, but there's still no trashcan icon, so they can't be deleted at all. Cropping tools don't make sense for SVGs, but it is nice to have thumbnails and a shared field for all types of images.
    1 point
  35. http://sachinchoolur.github.io/lightGallery/demos/videos.html
    1 point
  36. http://modules.processwire.com/modules/jquery-file-upload/ https://github.com/adrianbj/FieldtypeVideo
    1 point
  37. These days I would handle this issue with CSS: div:nth-of-type(even) { } div:nth-of-type(odd) { } But since it took me a while to understand this modulus operator stuff I'll give you an example: <?php $i = 1; foreach($page->repeater_field as $repeater) { $i++; // 2, 3, 4, 5, etc echo '<div class="' . ($i % 2 == 0 ? "odd-item" : "even-item") . '">'; // % is the modulus operator echo '</div>'; }
    1 point
  38. Hi JeevanisM Oh, terribly, terribly old! No idea where those files are now, to be honest, but they were built with an older version anyway. However, it is not really necessary. Basically, the trick is in parent-child relationships. The simplest way to build a news portal is to create a home page and then create pages under that - one for each article. Using the PW API you can then list them on the homepage. See here: https://processwire.com/api/ref/page/children/ The first example produces all the children in an unordered list: <?php echo "<ul>"; // Render navigation for all child pages below this one foreach($page->children() as $child) { echo "<li><a href='$child->url'>$child->title</a></li>"; } echo "</ul>"; You can see that you could use any html markup you like, for instance your blocks. Processwire does not hamper what html/css/js you use - just think of the /site/templates/ folder as the root of your site and put it together as you would do for a static site - just with the API, if you get my drift. Now, that is the simplest example, but you can go lots of ways from there. If you wanted to have simple categories, then you can create category pages under your home page and then articles under those: home -- news -- -- I lost the election -- sport -- -- I won the race -- food -- -- I got fat That is the most logical site and you can use the parent-child relationships in the api to list things. With this sort of site, you can almost get away with creating just one template-file and using it for everything, as long as you want everything to look the same. However, you can get much more complicated. Using the Page Field, this allows you to list pages in your template that have a specific parent. So, for instance, you can use this for tags. Home -- tags (hidden page) -- -- tag1 -- -- tag2 By being hidden, the tags parent page does not appear in any menu structure you may create and nor is it accessible easily. However, the tag pages, the children are. Using a page field, you can now list those pages as a select dropdown. But you can also tell the field to allow you to create new pages from the dropdown - making it a perfect tagging system. Just a note: Don't be put off by the expression "page." In processwire, that is basically one data record. It can contain just one field or hundreds - doesn't matter. Basically, everything chunk of data that relates to a template is a page - but may not be used as a "web page" as such. However, it means all data, however simple, is treated uniformly throughout the entire system and is accessible using the API. There you go - not a tutorial as such, but maybe some clues for you. Good luck
    1 point
  39. Is this already in, "crop sizes from presets"? If we could have that with the core images field, it would make the croppable images obsolete, what I think would make things much easier. We only would need one images fieldtype and optionally can define "presets" or not. Wouldn't it? +1
    1 point
  40. Now available as a module on Github.
    1 point
  41. Good work! Regarding best practises, the only suggestion I have is that the tutorial should be changed to use environment variables for the database connection. This has several benefits, for an example It would be very easy to launch a separate development site, which uses a different database, because all you need to change is the environment variable when launching the development web container You could easily use the same config.php as a template for new sites You don't have to store sensitive information in your version control The config.php becomes more cloud compatible (i.e. a twelve-factor app) Also since the MySQL-container is linked to the web-container, the config.php can directly use the environment variables set by Docker. An example config.php would be $config->dbHost = getenv("MYSQL_PORT_3306_TCP_ADDR"); $config->dbName = getenv("MYSQL_DBNAME"); $config->dbUser = getenv("MYSQL_DBUSER"); $config->dbPass = getenv("MYSQL_DBPASS"); $config->dbPort = getenv("MYSQL_PORT_3306_TCP_PORT"); Obviously launching the web container(s) would need to include these variables too, e.g. docker run -e "MYSQL_DBNAME=mypwdb" -e "MYSQL_DBUSER=mypwdbuser" -e "MYSQL_DBPASS=mypwdbpass" --name celedev-site -p 8088:80 --link database:mysql --volumes-from celedev-data -d php-5.6-pw-celedev Just my two cents
    1 point
  42. maybe this could help https://processwire.com/talk/topic/9655-pre-release-remote-backup/?hl=%2Bbackup+%2Bfiles
    1 point
  43. Okay, I will address the Pages issue - I am somewhat famous for it! To start: https://processwire.com/talk/topic/2296-confused-by-pages/ And once you have that out of your system, here is the real info. Basically, a page in Processwire is just a container for content - nothing more. So, it could be a: Web Page News Bullitin Block of info Some strange widget An option for a dropdown selector A gallery item A review Something that gets stuffed into something else! A parent of some other group of pages, A child of something Basically, it is just an item that is created using the criteria of a template. It does not need to have a template file associated with it - if you are using it as a simple option in a drop down, what would be the point? Fields from a particular page can be called into another template or page or anything else, either singularly or rendered as a group. The contents of a page need a template file to be displayed on the site as they are, but not if they are being displayed by something else. Confused? The bottom line is don't think of a page as a "page" that you would get in Wordpress - just think of it as a container for data that can be used for anything at all. This is why Processwire is a TRUE content management system - because all the elements are simply tools to help you manage content, they do not force you to make your content any particular shape.
    1 point
  44. Why so many template files? Is there any duplication between what you are doing from one template file and another? If so, remember never to repeat yourself and keep reusable stuff in separate includes, functions or modules. Also consider whether the different template needs might instead translate to stylesheets. But I know you have a good handle on all this stuff, so going to assume you really do need a lot of template files. In that case, I would suggest doing something like you indicated and considering your templates to be something more like template groups instead. Create a structure of pages that represent your "sub templates". Make them selectable, so that when you edit a template, you'll have a select box where you can choose a sub-template (with a field named sub_template). You can translate that page selection to a filename off a subdirectory in your /site/templates/ directory. For instance, lets say you are creating a page with template "news" and you want to have sub-templates of cnn, nbc and abc. You'd have a page structure like this to represent them: /sub-templates/ /news/ /cnn/ /nbc/ /abc/ And a template file structure like this to represent them: /site/templates/news.php /news/ cnn.php nbc.php abc.php Your news.php file might look like this: include("./news/{$page->sub_template->name}.php"); What I'm trying to get at here is that you can create a structure of pages to represent a structure of templates.
    1 point
  45. Hi, and welcome to the forum! What you are asking is not that simple because this is not the way that ProcessWire is designed to work. It's not impossible though, and if you have the skills to create a module you can do it. I can't help you a lot with this, but maybe someone who can will jump in the discussion. What I can do is help you to get started. Here it goes To make a page appear in the admin navigation, you just have to make sure that it is children of the admin page in the tree. You can do this with any page with any template. If you want this page to behave and look like the other admin pages, you will have to give it the admin template... go ahead an try it... when you do this, the page will simply say "This page has no Process assigned". This means, you will have to create a process module that does what you want and assign it to the page you created. If you edit the page and choose from the several processes that already exists, you can see how it works. The process modules are on the wire/modules/Process folder of your PW install, have a look at some of them to get a feel of how it works.
    1 point
×
×
  • Create New...