Leaderboard
Popular Content
Showing content with the highest reputation on 03/11/2014 in all areas
-
Recently I got a brand new iMac so I needed to install PHP SQL and configure Apache. I'm using the same web develop environment for years and I'm really happy with it. Raymond is also using this and Arjen did the same recently. I love to share how I setup this environment in a step by step tutorial. Let's setup PHP, MYSQL and activate mail using gmail smtp for OSX 10.6 and up, perfectly suitable for ProcessWire. It doesn't install Apache, it uses the Apache installation, which comes with OS X. The PHP installer package is created by Liip and it is based on entropy's php package. For MYSQL we gonna install the DMG Archive (x86, 64-bit). After we installed PHP, we configure Apache & PHP so that we’re able to run the ProcessWire sites in our own ~/Sites directory. For El Capitan see Arjen's https://processwire.com/talk/topic/5797-setup-a-processwire-environment-on-a-fresh-macos-x-install/?p=103674 Install PHP We gonna use the PHP installer created by Liip. (more information) Go to: /Applications/Utilities/ Open: Terminal.app Type: curl -s http://php-osx.liip.ch/install.sh | bash -s 5.5 Press: RETURN Type: your admin password Press: RETURN ( download starts and continues with a the install ) note: If you want to have an older PHP version, replace 5.5 with 5.4. (PHP 5.5 is the current stable) After the install is completed Apache is restarted and complains about “Could not reliably determine the server's fully qualified domain name, using your-computer-name.local for ServerName”. This notice is not a problem, we only use this Mac for local website development. Setup Apache Open a new finder window. Press: shift + command + g ( Go to folder ) Type: /etc/apache2/ Press: go Open: httpd.conf Find the line: #Include /private/etc/apache2/extra/httpd-vhosts.conf Remove the # infront to enable. Press save and enter your password when asked. Enable the use of ~/Sites folder:Open the folder /etc/apache2/users/ * Duplicate the Guest.conf and name it martijn.conf Open the duplicated file that we created * Change: <Directory "/Users/Guest/Sites/"> to <Directory "/Users/martijn/Sites/"> Change: AllowOverride None, to AllowOverride All Save the file. The file should look like: <Directory "/Users/martijn/Sites/"> Options Indexes MultiViews AllowOverride All Order allow,deny Allow from all </Directory> Configure the vhosts includes Open /etc/apache2/extra/httpd-vhosts.conf Comment out the 2 VirtualHost examples by putting a # in front Be sure that NameVirtualHost *:80 doesn’t start with a # sign. * Add the include: include /Users/martijn/Sites/_vHosts/*.conf at the bottom of the file. Save the file, password will be asked. The file should at least have these two lines: NameVirtualHost *:80 include /Users/martijn/Sites/_vHosts/*.conf * ( Replace martijn with your short admin name ) The ~/Sites folder (Users/martijn/Sites) Goto your user Home folder. Create the Sites folder in your user home ( if not exist ) Create inside the Sites folder a folder called _vHosts Create the folder domains inside the ~/Sites folder Create a folder inside the domains folder called processwire ( processwire will be the domain name ) Inside the processwire folder create 2 directories: 1. htdocs 2. logs ( make this writeable by right click the folder and choose Get info ) Create inside the htdocs folder a file called index.html with some content. The folder structure should look like: ~/Sites |`-- _vHosts | `-- domains | `-- processwire | |-- htdocs | `-- index.html | `-- logs Configure PHP Open the file: /usr/local/php5/php.d/99-liip-developer.ini ( This file is the last ini file that gets loaded, so perfectly suitable for your personal settings ) Make your personal changes here. ( setting xdebug.max_nesting_level=1000 for example if needed ) Save the file ( password will be asked. ) Make an alias the this file by right click and choose: Make Alias Name the alias _settings.ini or what ever you want to name it. Move the alias to your ~/Sites folder Create a vHostIn our ~/Sites folder we created a folder named _vHosts. This folder we gonna use for the vHosts. All files ending with .conf in this folder will be loaded when we (re-)start Apache. Create a new file with your favourite text editor. Type the following in the file: ( Replace martijn with your short admin name ) <VirtualHost *:80> DocumentRoot /Users/martijn/Sites/domains/processwire/htdocs/ ServerName processwire ErrorLog /Users/martijn/Sites/domains/processwire/logs/error.log.txt CustomLog /Users/martijn/Sites/domains/processwire/logs/access.log.txt common </VirtualHost> Save the file with the filename processwire.conf in the folder _vHosts The hosts fileGo to the Finder Press: shift + command + g ( Go to folder ) Type: /etc/hosts & press return Open the hosts file with you favourite editor Type 127.0.0.1 processwire below 127.0.0.1 localhost but above 255.255.255.255 broadcasthost Save the file Right click the file & choose: Make Alias Move the alias that you created to your ~/Sites folder Rename it to _hosts The file should look like: ## # Host Database # # localhost is used to configure the loopback interface # when the system is booting. Do not change this entry. ## 127.0.0.1 localhost 127.0.0.1 processwire 255.255.255.255 broadcasthost ::1 localhost fe80::1%lo0 localhost Test the Apache & PHP setup Go to: /Applications/Utilities/ Open: Terminal.app Type: sudo apachectl restart Press: RETURN Type: your admin password Press: RETURN At this point Apache & PHP will be up and running.Go to a browser and type: processwire/ in the address bar and press enter. MYSQL For managing MySQL databases I use Sequel Pro it's a very handy tool and in this tutorial we set the root user password with it. For the SQL server we gonna use the MySQL DMG Archive (x86, 64-bit) Download the following: MySQL DMG Archive (x86, 64-bit) Sequel Pro Open the mysql-5.6.16-osx10.7-x86_64 image * install mysql-5.6.16-osx10.7-x86_64.pkg, MySQLStartupItem.pkg & install the prefPane * if MACOSX complains about: ( mysql-5.6.16-osx10.7-x86_64.pkg” can’t be opened because it is from an unidentified developer. ) You should open your System Preferences, go to Security & Privacy and Allow apps downloaded from: Anywhere Set the root user password Double click the sequel-pro-1.0.2.dmg. The disc image will mount Drag'n'drop the Sequel Pro.app to your /Applications/ folder. Open Sequel Pro Type by name: 127.0.0.1 Type by host: 127.0.0.1 Type by username: root Login Press command + u Select the root user on the left side Fill in the password Press apply We're Done ----- Todo how to use it after the setup is complete10 points
-
Well it requires some knowledge and understanding of ProcessWire, so I lied when I saids soo easy. It's the where to hook what and how and when and what is returned and what are the arguments. Some are rather simple to figure out and some are very hard. Some even took me long time to get right, try and error But nonetheless the basic concept is easy to grasp and some good and simple hooks are in the HelloWorld.module, that's where I started too 2 years ago. This is example module that does remove the "new" on second level basic-page pages in the page tree. This only modifies the actions and does not prevent adding child pages via API elsewhere. This hook is tricky as it also is all called via ajax in the page tree, so you can't simply echo something to debug. ProcessPageList.module is the module where the actions are done, but it contains 3 classes actually, and you need to hook into ProcessPageListRender::getPageActions, catch the $options array this method returns which contains all actions as a nested array. If a method returns something you can catch it with the $event->return. So all you need to do is to remove the "New" action from the array and set it back to the $event->return. Easier said than done. Here's a basic example module https://gist.github.com/94938776 points
-
4 points
-
https://gconverter.com/convert-processwire-to-wordpress/ Somehow, I doubt the creators of this service have ever even looked at ProcessWire - just filled in the PW name into the blanks on their template.3 points
-
3 points
-
Here's another one that does the "same" with a different hook on Page::addable. It's basicly the same, but this time we just set Page::addable to false and since the page list tree actions do check for this permission to add the "new" button, they simply won't get rendered anymore. So two ways, same result. The difference is that Page::addable is also used by ProcessWire in other places not just page tree. So will not be able to add a page and see an error when you try to add a page manually with a link like /processwire/page/add/?parent_id=1001. So this may the better solution here. Here the example module on my ever growing gist archive (hmm btw are those limited?) https://gist.github.com/somatonic/94944273 points
-
That just means you didn't properly close some tags or use a semi-colon to tell PHP you have come to the end of a line just before you come to the echo...and...as you can see, you are missing a semi-colon ; after the closing ) in your array...Hence, the echo is "unexpected....you haven't told PHP you have finished your array ....and it's telling you your syntax is wrong...3 points
-
3 points
-
Just use $input->whitelist(key,value) to store get vars and pager will auto include it.3 points
-
Don't know if there's a real benefit for this in-comparison with MAMP (no experience with MAMP). I started this setup before MAMP was there and it works without problems. It works with the default Apple shipped Apache & in the past you could turn on/off apache in your System Preferences. I do like the fact that I don't need an extra GUI app to put the environment on and off. Every time I start the machine Apache PHP & SQL is loaded, no questions asked. I especially like the ~/Sites setup. I can see the logs from the website working on directly in the same folder. There's room enough to store information needed next to the site when building. And It's all In your user home folder.3 points
-
One...you can easily upgrade your software version (e.g. PHP) without waiting for MAMP to upgrade...But am lazy...so I still use XAMPP Martjin. Thanks for this write-up! Very helpful not only for MAC users, but the ideas are applicable to other environments too.3 points
-
2 points
-
But master do i more painting. Avatar is done a self portrait using my bug (you call mouse) in photoshop 17 years ago actually. So i look little older now.2 points
-
I'm probably not the slowest but by faaar not the fastest. I have my own finger system and writing English and code half blind and writing on computer since 26 years now may helps a little. But by no means do I master coding or using all potential of editor. I'm a creative who loves coding.2 points
-
2 points
-
Don't know, but if yes, we will buy you additional space! Soma, you write complete modules in the same time where others write a single line of code. (a little bit frightening)2 points
-
@horst thank you for helping and pointing out a way to log the file names to see what is going on. I have placed both lines inside the WireMailSmtp.module and posted the form a few times to find out that nothing is logged. The code is right because putting the following line in the __construct() created the expected log file correctly. wire('log')->save( "debug_attachments", "tralalala");I came to the conclusion that form builder is not realy sending the files as attachments. All it does is save the attachments to /assets/cache/form-builder/form-x/entry-x/ and rendering a 'special' link to those files. So now i'm sure the bug is form-builder related and not in your WireMailSmtp and/or WireMailSwiftMailer module.I will report it in the form-builder forum and see if i can find out something more to backup the bug report with. Update: Haha Ryan is always 3 steps ahead I found this line in InputfieldFormBuilderFile.module // @todo this is producing invalid file links when more than one file on the page2 points
-
i think there will always be a use for this, even if you can easily create your custom pages in a process module; the other day i was in a meeting and the client asked for a point-of-sale page in their admin, using foxycart, but with blank fields; so with a few clicks and a 5 line form they had their POS and were able to use it within 10 minutes; i could go now and tighten it up and make it into a process module, but this is a low budget site, so they actually can't afford that.2 points
-
First of all: Thank you for all you support during the last month! It took some time but finally my new website is online: http://www.lange-belichtung.com/ It is my first site running PW and I would like to thank for this real alternative to MODx To understand PW I decided to build my own gallery script for easily managing images. Some facts: - using EXIF data to prefill necessary fields (e.g. title, meta description, alt tag, etc) - keeping an original (non-resized) image and adding a "canonical-link" for every smaller copy to reference the original - some images are availabe as wallpaper in different resolutions + resolution recommendation based on your monitor ... I hope you will like it even it is only in German language.2 points
-
Hooks are sooooo easy that I have hard time seeing what people are afraid of. Once I get a minute ...2 points
-
Enable advanced mode config. Select fieldgroup underneath the fields from the original template instead of adding them again. It then references the fieldgroup. Or have a hook into the page list action to remove or don't allow 'new' from those pages that have certain level.2 points
-
I agree that it's not difficult to create simple process modules, but I think it's great to be able to use normal templates in the admin. The idea of the module is that people don't have to change the way that they write code in pw or learn a new concept just to create a couple of backend pages. I do think that the module makes it easier to create admin pages (when it's working at least). I'll try to fix it as soon as I have some time. Edit: I didn't use the module for some time, but I did it now and I'm always amazed with how easy it is to create a custom page with it2 points
-
I agree — ProcessModules are the way to go. They might look intimidating at first, but if you start with a very simple example, they really are very easy. Here is a super simple example that lists all pages with the template "news". (I'm sure there are others out there, but it only took a few minutes to write so...) <?php /** * Simple Process Module Example. * This is a very basic example to learn from. * I have no intention of expanding on this sample module. * * @author renobird * * ProcessWire 2.x * Copyright (C) 2011 by Ryan Cramer * Licensed under GNU/GPL v2, see LICENSE.TXT * * http://www.processwire.com * http://www.ryancramer.com * */ class SimpleProcessModule extends Process { public static function getModuleInfo() { return array( 'title' => 'Process Module (basic example)', 'summary' => 'A very simple process module as an example on how easy they are to create.', 'version' => 100, 'href' => '', 'permission' => '' ); } public function init() { // initialize the parent parent::init(); } public function ___execute() { // Find some pages $items = $this->pages->find("template=news"); /** * Create a table to display results * There are other ways to do this using MarkupAdminDataTable module, but let's keep this simple for now. */ $out = "<table width='100%'>"; $out .= "<thead>"; $out .= "<th>Title</th>"; $out .= "<th>Date Created</th>"; $out .= "<th>User</th>"; $out .= "<thead>"; $out .= "<tbody>"; // If $items pageArray is not empty if ($items->count() > 0){ foreach ($items as $item) { $out .= "<tr>"; $out .= "<td><a href=". $this->config->urls->admin . "page/edit/?id=" . $item->id .">" .$item->title . "</a></td>"; // title $out .= "<td>" . date("F j, Y", $item->created) . "</td>"; // date created $out .= "<td>" . $item->createdUser->name. "</td>"; // user that created $out .= "</tr>"; } } else { // empty pageArray message $out = "<tr><td>No pages matching your criteria were found.</td></tr>"; } $out .= "</tbody>"; $out .= "</table>"; return $out; } } Usage: Install the module Create a new page under /admin/ Set the process for the new page to SimpleProcessModule If you have never created a module, just focus on the execute() method. Most of what is there is coded exactly as you might from a page template.2 points
-
You're abosolutely right. It's a tad more efficient than $page->parent->id as well as ProcessWire isn't having to load the parent page into memory to get the ID. If you click on $page->parentID on the cheatsheet there's also an alias of parentID called parent_id which does the same thing.2 points
-
Thank you Pete for these explanations. I really appreciate help in php matters. Ah, but in the cheatsheet it does. And in fact if ($page->parentID == 1016) is working like expected.2 points
-
In some cases Kimono might be overkill. If all you want is to extract some simple info from a webpage you can use an html parser. Here's an example using http://simplehtmldom.sourceforge.net/ <?php include "simple_html_dom.php"; $html = file_get_html('http://www.wunderground.com/cgi-bin/findweather/hdfForecast?query=porto,+portugal'); $location = $html->getElementById('#locationName')->plaintext; $temperature = $html->getElementById('#rapidtemp')->find('.b')[0]->plaintext; echo "Temperature in {$location} is {$temperature} °C"; //echoes "Temperature in Porto, Portugal is 22 °C" (that should make most of you jealous )2 points
-
Just to explain what went wrong - firstly, parentID doesn't exist. You would use $page->parent->id as in the corrected example above, so you are saying "this page's parent's ID" (or "the ID belonging to the parent of this page" if you read it from right to left, which sort of makes more sense if you read it to yourself that way). The other issue was = versus == which I'll cover below: // A single equals sign means you are assigning a value of 1016 to $page->parent->id in this case: $page->parent->id = 1016 // So literally, $page->parent->id now has a value of 1016 because you told it to. Similarly, $something = 'a value'; means that if you echo $something it will output "a value". // A double equals sign means "equals", so if ($page->parent->id == 1016) { // means "if $page->parent->id is equal to 1016" There are lots more ternary operators besides == which you can read up on here, as you'll probably use some of them a lot: http://uk3.php.net/ternary2 points
-
I don't know FormBuilder. wireMail()->attachment() needs an absolute path for every (disk) file it should attach to a message. You can pass it as array or have to call it multiple times. Here are all is working as expected. Maybe you can debug what is passed to the attachment function when running with FormBuilder? You can call a log here wire('log')->save( "debug_attachments", strtolower(__FUNCTION__).' :: '.serialize($filenames)); // ATTENTION this is $filename(s) ending with s and here wire('log')->save( "debug_attachments", strtolower(__FUNCTION__).' :: '.serialize($filename)); // ATTENTION this is $filename, without s Trying this with passing an array logs something like: 2014-03-11 14:04:36 guest http://pw4.kawobi.local/mailtest/ attachments :: a:2:{i:0;s:75:"W:/WEB_MIRRORS/_ProcessWire/pw4/htdocs/site/assets/files/1/hyatt2.0x100.jpg";i:1;s:79:"W:/WEB_MIRRORS/_ProcessWire/pw4/htdocs/site/assets/files/1/westin_interior1.jpg";} 2014-03-11 14:04:36 guest http://pw4.kawobi.local/mailtest/ attachfile :: s:75:"W:/WEB_MIRRORS/_ProcessWire/pw4/htdocs/site/assets/files/1/hyatt2.0x100.jpg"; 2014-03-11 14:04:36 guest http://pw4.kawobi.local/mailtest/ attachfile :: s:79:"W:/WEB_MIRRORS/_ProcessWire/pw4/htdocs/site/assets/files/1/westin_interior1.jpg"; Calling it multiple times (2) with string filenames: 2014-03-11 14:10:10 guest http://pw4.kawobi.local/mailtest/ attachments :: s:75:"W:/WEB_MIRRORS/_ProcessWire/pw4/htdocs/site/assets/files/1/hyatt2.0x100.jpg"; 2014-03-11 14:10:10 guest http://pw4.kawobi.local/mailtest/ attachments :: s:79:"W:/WEB_MIRRORS/_ProcessWire/pw4/htdocs/site/assets/files/1/westin_interior1.jpg"; 2014-03-11 14:10:10 guest http://pw4.kawobi.local/mailtest/ attachfile :: s:75:"W:/WEB_MIRRORS/_ProcessWire/pw4/htdocs/site/assets/files/1/hyatt2.0x100.jpg"; 2014-03-11 14:10:10 guest http://pw4.kawobi.local/mailtest/ attachfile :: s:79:"W:/WEB_MIRRORS/_ProcessWire/pw4/htdocs/site/assets/files/1/westin_interior1.jpg";2 points
-
@horst....Raymond is quoting what Ryan said. That was a typo (I believe, by Ryan), although he did it twice, which is baffling. See the post here:2 points
-
@Raymond: Hi, this sounds that you have get the PW 2.4.0 stable. - If you have the right version, you must see at least a 2.4.1 in the backend Version 4.3.1 isn't known. Current stable is 2.4.0 and DEV is 2.4.12 points
-
Good clarifications from both of you This is getting a bit out of hand, but one more addition: in current code image isn't actually resized -- it's just forced to specific dimensions with HTML attributes. This could be intentional, but I'm wondering if this might make even more sense here: ... echo "<img src='{$p->images->first->size($resized_imageWidth, $resized_imageHeight)->url}' width='{$resized_imageWidth}' height='{$resized_imageHeight}'>" . "<a href='{$p->url}'>{$p->title}</a><br />"; ... This way end-user doesn't have to download excessively large images, if what you really want here is a thumb. It should also be noted that simply defining width and height with HTML attributes forces image to those exact dimensions without considering actual aspect ratio, which can easily result in distorted images. (More about various options that size() accepts here.)2 points
-
Since we're in a clarifying mood , the catch with $p->viewable is that there must be a template php file for the page, so this isn't a complete fix for using ->get and making sure it is not hidden/unpublished. Maybe this instead of viewable? !$p->status>=1024 I know it won't matter for this script because we are looping through pages that were at some point viewable (even if the status was changed in the meantime), so they must have had a template file at some point and likely still do. Sorry, I know I am getting too pedantic and off-topic now - time to sleep2 points
-
Another clarification. (I seem to need these a lot these days.) As is (probably) made quite obvious by the SQL statements above, get() with a Page ID doesn't care about the status of the page at all. It returns hidden and unpublished pages too, making it somewhat equal to find() with "include=all". This is important to keep in mind in case that those pages you're "getting" could've been unpublished in the meantime; if that's possible, you really should add another check for $p->viewable() before displaying content. With this addition, nfil's final code could look like this: $resized_imageWidth = 120; $resized_imageHeight = 0; $session->history = is_array($session->history) ? array_slice(array_merge(array($page->id), $session->history), 0, 4) : array($page->id); foreach ($session->history as $page_id) { $p = $pages->get($page_id); if (!$p->viewable() || $p->template != "basic-page") continue; echo "<img src='{$p->images->first->url}' width='{$resized_imageWidth}' height='{$resized_imageHeight}'>" . "<a href='{$p->url}'>{$p->title}</a><br />"; }2 points
-
Very good clarification. My explanation earlier was way too vague What I meant was that you can't find from a single page, i.e. use find like a filter for one page. You can find from children of given page, though: $pages->get(123)->find("template=basic-page") would return children of page 123 with template "basic-page" recursively, while $pages->get(123)->children("template=basic-page") would only return matching direct children. That's another way to do it. With find() you could also do something like this to, perhaps, simplify it a bit: $p = $pages->find("id=$page_id, template=basic-page")->first(); if (!$p) continue; echo .... Quick look at the SQL generated by get() vs. find(): SELECT id, templates_id FROM pages WHERE id=1001 SELECT pages.id,pages.parent_id,pages.templates_id FROM `pages` WHERE (pages.id=1001) AND (pages.templates_id=29) AND (pages.status<1024) GROUP BY pages.id /* Selector id=1001, template=basic-page, status<1024 */ I would assume first one (get) to be slightly faster, but this is micro-optimisation at it's best and doesn't usually matter at all in real world use. I prefer get() for getting single pages as it's the straightforward way2 points
-
I looked at some things and pushed some changed to 1.3.1, I think you'll be able to do what you need Changes in 1.3.1 Minor refactoring and optimizations Added support for having placeholder in inner_tpl's opening tag. So you can now also add dynamic values to the opening tag like, much like in the item_tpl 'inner_tpl' => "<ul id='{name}' class='drop-down'>||</ul>", That will result in {name} being replaced by the name of the page (containing the inner childs) To hook into the parsing of the the list opening template you can use the "MarkupSimpleNavigation::getInnerStringOpen" and do you're own conditional replacements.2 points
-
I used to find shouting a lot and copious use of a 12-bore worked quite well - does that still apply? Seriously, I think nothing beats being face to face and making a performance out of the presentation. The software is almost irrelevant. I used to work with a chap who reckoned a creative presentation should go something like: Premise Brief Target Solution Benefits Projection Stripper (male or female depending on the client preference) In a way he was right. (Actually, he was very good at this, so he was absolutely right). For instance, your vocal presence has far more potential than any bit of software or technology and learning how to use it will make more difference than anything else to the presentation. If you are not happy with the sound of your own voice, it is really something worth working on - join a local amateur dramatics society or something. So, if you can make the presentation exciting, if you can really draw the client in and make them trust you, then they will take on board your ideas however you present them. One trick sales people used to tell me was that you should NEVER let your client find their way through anything. As soon as they sit down and pay attention, you take them through everything - none of this "well you will find out more as you explore later" stuff, just take them through all the big important stuff and make it sound as exciting as possible. One of the earliest presentation tools was the overhead projector. When power-point gained popularity, I knew several serious sales people (my brother included) who hated it. With overheads, there was this big theatrical thing of whipping off one cell and replacing it with the other. It meant you had to be on your feet, had to move round and grab for things and really get involved with the technology. It was a really great prop that got replaced with a mouse. Oh, one note - I am a terrible sales person (I scare people I think), but I worked with some brilliant ones who were selling my concepts. So back to web briefs, maybe the trick is to use great big print outs to shout and sing about the product, then end the performance by beaming the website onto everyone's mobile phone at once: "And the best thing about this huge, wonderful, singing and dancing concept, is that the entire thing can be neatly packaged up and enjoyed on a mobile phone." Brrrrrr Crash.2 points
-
Spectacular. I just moved a blog tree to another dev site which has saved me a good hour of setup time. Thank you!1 point
-
Yes, works like a charm. But also I discovered 2 issues. 1.- the csv have not \n line endings. 2.- the sql export have all the sessions. that was the main reason it was a very huge sql file (near 12 megas) after the truncate only was 140 kb. wow. Thanks folks!1 point
-
1 point
-
Note that by default, the function json_decode() returns an object. If you try to foreach that you will get an error like "Fatal error: Cannot use object of type stdClass as array in...". So, you need to use the 2nd parameter of the function to return an array..e.g. $array = json_decode($jsonstring, true) http://php.net/manual/en/function.json-decode.php Having said that, your json string above results in a deeply nested array (multi-dimensional) which can be a pain to traverse....unless you know about stuff like these Even Better... http://php.net/manual/en/spl.iterators.php http://stackoverflow.com/questions/5524227/php-foreach-with-arrays-within-arrays/5524267 http://www.phpro.org/tutorials/Introduction-to-SPL.html http://www.sitepoint.com/using-spl-iterators-1/ http://codepad.org/A68lcnLZ [demo]1 point
-
I'm not sure what is involved in the importer process when getting only a basename. Does it check the current working directory? If yes is this save? I think no. PHP has a function to get the current working direction: getcwd() but if I remember right it is different if running as CLI or running in WebserverEnvironment. Also I don't know if ./filename.typ works. I always want these things robust - bulletproof and therefor I ever use absolute pathes.1 point
-
I tend to agree with horst on this, but it can make life a lot easier if you learn some basic implementations of ternary operators, depending on how you want to structure your html and php. This can be easier: echo $page->Departure_AUI ? "<div>Aui: {$page->Departure_AUI}</div>" : ""; In my mind it really comes down to whether that div can be left empty, or if it must not be echo'd at all, which depends on your layout. It can also be easier sometimes to build up sections of content in a variable first. $out = ''; $out .= $page->Departure_AUI ? "<div>Aui:{$page->Departure_AUI}</div>" : ""; $out .= $page->Departure_MAG ? "<div>Mag: {$page->Departure_MAG}</div>" : ""; echo "<div id="block-parent">$out</div>";1 point
-
alternatives: http://processwire.com/talk/topic/5640-shortest-way-to-echo-a-field-only-if-populated/ But if I were new to PHP I would write a few chars more and have better readability. EDIT: damn, Kongondo!1 point
-
Like those shown here... http://processwire.com/talk/topic/5640-shortest-way-to-echo-a-field-only-if-populated/1 point
-
Each page that is shown is only a template file with fields rendered on it. So, if the front page of this site, the landing page, is meant to be the users home page, then this is not a problem to use just home.php as default. Once a user logs in, then the page will display information relating to that particular user. You can also decide what to display based on role - if a user has a particular role (like admin) then you can just check if they have that role before displaying that information. On the front end of the site, you can display anything you like in any order you like. You do not have to reflect the page tree element for element - people tend to do that simply because it makes it easier to manage, but it is not vital. So. the ROOT of the site is home. (core has nothing to do with anything here - forget about it). Home is your landing page and you can use it for anything. So, you could use it for an entire dashboard which is only shown if a user is logged in, or you can use it for something else. You could write in php if($user->isLoggedin()){ lots of page stuff }else{ login form } All websites have a landing page and, logically, that page is ALWAYS at the top of a tree. Once they are logged in, you can stay on the home page (and home template file) and show them all the bits they need to see on their landing page. Then you can just build stuff under home: Home --Profile ---- Manage ---- Messages ---- My picture ---- My docs -- Company News -- Club ---- Club venues Whatever you need to do. You can either have a top menu that follows the same logic (but perhaps tell it not to display certain elements unless they are logged in) or you can just have a menu in each section that calls information from any part of the tree you like. THIS IS IMPORTANT - when we create menus that follow the tree, you will notice that they ignore the home page initially then add it back on. This means, as far as the front menu is concerned, Home, Profile, Company News and Club would all be on the same level. Even though Profile, for example, is actually a child of Home. So, for your front end, Home is your landing page, and the others are you toplevel main menu items.1 point
-
@Zahari: nice video, nice car. Maybe you find this interesting for some stills in your videos: http://www.photofilmstrip.org/1-1-Home.html I have used it here on this old (and private) site where a 6 year old child want to present his new built time machine. (the video is the sepia one)1 point
-
I don't think there's any need in changing the homepage to "core" and putting a "home" page underneath it. The way it's setup by default is that all content is a child of the homepage - the homepage being the start of the website. Why not simply create a "Profile" page under home and put these pages under the Profile page: Calendar | Messages | Projects | etc ? If the user is logged in you then show the Profile page else show a Login page. Or are you trying to have customised home pages for each user?1 point
-
If this is your ideal structure, there's no need to change only because of the frontend. There are many ways to make the frontend adapt to the structure. One would ve in the htaccess file, others can be done in the templates themselves. Simplest way would have to have simply: $session->redirect($page->child->url);, this would redirect the "core" to it's first child, the "home". The problem with this approach is that you would have "site.com/home" as the url of your home page instead of simply "site.com", the advantages are that you would have a very easy to create navigation and a one-to-one relation between the backend and the frontend. Another approach would be to render "home" from the "core" url, by putting this code on the "core" template: $page->child->render();, and excluding "home" from lists and searches: "settings > hide". Advantage -> you keep "site.com" as your main url, disadvantage -> you alter the structure and home is not searchable anymore without explicitly including it on find() searches. Edit: to make it clear, I agree with what Pete says below. My suggestions are only for the case you really want to keep that structure.1 point
-
Hi all, today I finally managed to get everything working together properly. Now here is my Foundation 5 dropin template: https://github.com/gebeer/pwfoundation5. It uses Foundation 5 SCSS files. There's a quite extensive readme file with instructions. The template is based on Ryans FoundationSiteProfile. My approach takes advantage of the SASS/SCSS/Compass technology. So the output of the final CSS is highly customizable and only one file (style.css) is put out. You have full control over which modules of the Foundation framework you want to include in your project. This results in smaller CSS files that can be minified upon compilation with Compass. You can use the template as is. But if you want to modify the CSS, you need to have additional software (Ruby/Compass/Zurb Foundation gem) installed on your machine. In the template's Readme.md you will find instructions on how to do this (for Mac and Linux machines - Windows: sorry I don't know). If you are familiar working with SASS/Compass you will find your ways around easily. I have setup a structure that allows for updating the Foundation framework independently and that separates the project specific css from the Foundation css. This is a work in progress and I'm planning on using it for the relaunch of my own website. If you find any bugs, please let me know here or on the github bug tracker. I will try to fix them. Everyone is welcome to contribute or ask questions. Cheers gerhard1 point
-
Had the same problem, and it turned out to be a classic: On Ubuntu, the default Apache configuration has turned off the "AllowOverride" setting for /var/www, so I had to edit my /etc/apache2/sites-enabled/000-default file like this (the changed part in bold text): From: <Directory /var/www/> Options Indexes FollowSymLinks MultiViews AllowOverride None Order allow,deny allow from all </Directory> To: <Directory /var/www/> Options Indexes FollowSymLinks MultiViews AllowOverride All Order allow,deny allow from all </Directory> ... and then restart apache with: sudo service apache2 restart (Didn't even need to change the RewriteBase setting in my .htaccess file, although I have a subfolder named "procwire") Hope this helps!1 point