Leaderboard
Popular Content
Showing content with the highest reputation on 10/02/2014 in all areas
-
6 points
-
@pwired Is there a particular reason for this? I'm with diogo on this one. I went through a phase of wanting to put everything as tersely as possible in PHP but I don't do that any more. I find single liners make it more difficult to see structure (where's the closing brace for the if statement in diogo's example above?), more difficult to read, more difficult to debug (especially if you single step with a debugger), more difficult to edit and more difficult to maintain than using multiple lines. Vertical space in a good text editor is almost unlimited - and easily navigated around. I'd rather pay the price of a few more lines of code to be able to instantly see the structure, closing braces and be able to step through the code line-by-line.3 points
-
3 points
-
What if there's no such image? I think it's not about making it shorter but more fool proof. <?php if($page->images->count) { $image = $page->images->get("name=logo.jpg"); if($image) echo "<img src='{$image->width(200)->url}'/>"; } ?>3 points
-
HEY, Thank you all for your comments! My client loved seeing them too, so thank you. The site is now live: http://horton-stephens.com/ Tutorial coming this week, anything in particular people would like to know? Thanks3 points
-
One Linux distro can be very different from another Linux distro in what comes pre configured or pre installed. Sometimes when you finish a Linux distro installation you still have to install some packages or do configurations for everything to work what you need. Example, I have become very fond of Linux Antix because it is both very user friendly and fast on cheap motherboards. After doing a Linux antix installation your wifi does not show up because you have to manually add the wlan card to the network configuration. So maybe in your case simply installing another Linux distro might solve you from difficult to find configurations that did not came during the Manjaro installation. The Manjaro distro is based on Arch Linux so I recommend to go through this Lamp page step by step: https://wiki.archlinux.org/index.php/LAMP3 points
-
This is put together very quickly, but should work ok. If the user is logged in, but they don't have page-edit permission, and they try to load any page with the admin template, they will be redirected to the site's homepage. Of course you can tweak these as needed. <?php class HideBackend extends WireData implements Module { public static function getModuleInfo() { return array( 'title' => 'Hide Backend', 'summary' => 'Redirect guest user from backend admin back to site\'s homepage.', 'href' => '', 'version' => 1, 'permanent' => false, 'autoload' => 'template=admin', 'singular' => true, ); } public function init() { if($this->user->isLoggedin() && !$this->user->hasPermission("page-edit")) { $this->addHookAfter('Page::render', $this, 'redirect'); } } public function redirect(HookEvent $event) { if($this->page->template == "admin") { $this->session->redirect("/"); } } }3 points
-
Hey Everyone! right I'm nearing the end of development on this photography agencies site and I was wondering if anyone could have a quick look for bugs etc. http://nicegrp.co.uk/dev/hs/ It's not quite finished so there may be obvious stuff, also there's ALOT, going on in the front end, for example: - pages are cached client side (to prevent unnecessary ajax requests for seen pages) - Ajax page requests & pushstate - pdf module for gallery pages - slideshow animations - add image to your custom gallery - alot of menu logic - responsive - lazy loading images on gallery pages Let me know what you think. Thanks2 points
-
I don't see why bxslider wouldn't work. The markup it requires is very simple, just a ul > li > img with free urls (it doesn't enforce that you specify only the folder like some old scripts did). In your case I would probably just put the images in the css folder and call them manually. I mean, if you know the name of the files is because you don't need the images to be dynamic, so why have them in a PW field? $images = ["image1.jpg","image2.jpg","image3.jpg"]; echo "<ul>"; foreach ($images as $img) { echo "<li><img src='{$config->urls->templates}styles/slider_images/{$img}'/></li>"; } echo "</ul>";2 points
-
Here is your one liner, but I wouldn't advise you to use it: if($imageUrl = $pages->get("/bxslider-pictures/")->images->get("name=hill.jpg")->width(200)->url) echo "<img src='$imageUrl'/>";2 points
-
It's not really getting any better with this, but how 'bout something like this? (Written in browser, not tested, might not work, you know the drill.) <?php echo "<img src='" . $page->images->get("name=logo.jpg")->width(200)->url . "' />"; ?>2 points
-
Hi Stefan, image presentation on the web is a compromise between less loading and good image quality. If you can avoid to show the original image at the front end I would recommend to use those "only as resources" for the derivatives that are shown to the public. This way you should use the best quality for the original images, 100% quality, saved as default. Optimized Jpegimages have artefacts, more or less, depending on the quality setting. If you use an image that has already artefacts (q90 optimized for web) you will become artefacts of the artefacts, but at least more artefacts as from a resource image with q100 saved default. Which finally quality setting is usefull for your images you only simply can try out. I believe that you can use between 80 and 90 with good quality.2 points
-
I am working on Fedora 20. May be this would help you. <VirtualHost *:80> DocumentRoot "/home/user-2/dev/php/ProcessWire/pwire-2" ServerName pwire-2.localhost # This should be omitted in the production environment SetEnv APPLICATION_ENV development <Directory "/home/user-2/dev/php/ProcessWire/pwire-2"> Options Indexes MultiViews FollowSymLinks AllowOverride All Order allow,deny Allow from all # New directive needed in Apache 2.4.3: Require all granted </Directory> </VirtualHost> Thanks ------------------------------------------------------------------------ Edit: Add a comment for the new directive used for Apache 2.4.3 under <Directory> tag2 points
-
This Module didn't have it's real own thread, now it has Markup RSS Enhanced This Module is the enhanced version of Ryan's Markup RSS Module and is completely compatible with it. In addition, this enhanced module supports the usage of enclosures a way of attaching multimedia content to RSS feeds. Give the RSS enhanced module a PageArray of pages and it will render a RSS feed from it. The Module should be used directly from your template file. In the examples the $rss variable is used for as instance of the module. $rss = $modules->get("MarkupRSSEnhanced"); Basic usage In case you only need 1 feed for your site, you need to setup the defaults in the Modules config. then you can use the code below. $items = $pages->find("limit=10, sort=-modified"); // $items, PageArray of Pages $rss = $modules->get("MarkupRSSEnhanced"); // load the module $rss->render($items); // render the feed Setup channel elements The channel element describes the RSS feed. There are 3 required channel elements: title $rss->title link $rss->url description $rss->description $rss->title = ''; // (string) Title of the feed. $rss->url = ''; // (string) URL of the website this feed lives. Example: http://www.your-domain.com/ $rss->description = ''; // (string) Phrase or sentence describing the channel. $rss->copyright = ''; // (string) Copyright notice for content in the channel. $rss->ttl = ''; // (string/integer) Number of minutes that how long it can be cached. Setup item elements Every page from the PageArray use the item element. $rss->itemTitleField = ''; // Fieldname to get value from $rss->itemDescriptionField = ''; // Fieldname to get value from $rss->itemDescriptionLength = ''; // Default 1024 $rss->itemEnclosureField = ''; // Fieldname to get file/image from $rss->itemDateField = ''; // Fieldname to get data from $rss->itemLinkField = ''; // Fieldname to get URL from or don't set to use $page->httpUrl $rss->itemAuthorField = ''; // If email address is used, itemAuthorElement should be set to author $rss->itemAuthorElement = 'dc:creator' // may be 'dc:creator' or 'author' Item element enclosure RSS enclosures are a way of attaching multimedia content to RSS feeds. All files with proper mime types are supported. If you asign an image field to the itemEnclosureField there are 3 extra options you could set. width The width of the image. height The height of the image. boundingbox Checking boundingbox will scale the image so that the whole image will fit in the specified width & height. This prevents cropping the image $rss->boundingbox = 1 // (integer) 1 or 0, on or off $rss->width = 400; // (integer) Max width of the image, 0 for proportional $rss->height = 300; // (integer) Max height of the image, 0 for proportional Prettify the feed Prettifying the feed is not supported by all clients. $rss->xsl = ''; // path to xls file $rss->css = ''; // path to css Download on GitHub View on the modules directory1 point
-
Hello, I think it would be fun to nickname the Processwire versions like the mayor softwares (Wordpress, Ubuntu, Mac, etc). So I propose that versions should be nicknamed after scientists/inventors or cool people that make experiments because Processwire "ancestor" Dictator CMS was named after the Thomas Alba Edision's Dictator Machine. Also, nicknames could come from beer, wine or fantasy characters like Bilbo Baggins or Gandalf?. What do you think?1 point
-
1 point
-
Good to hear. I will put together some info about the bugs. I'm planning on featuring the ProcessMigrator plugin as a general exporter/importer of content from one PW site to another. For example, let's say you have a development and production version of a site, and a new set of content needs to be created (on dev), then eventually launched (on prod). Rather than re-creating that content manually on production, I want to show how your plugin can achieve that. WordPress has an export tool, however it's very limited and doesn't work that well for the situation I described. There are some plugins to enhance it but I haven't had great success with those either. There's one commercial plugin which I haven't used but seems to be the ultimate solution to do what I described: https://crowdfavorite.com/ramp/ ProcessMigrator, in my eyes, would be the analog to RAMP.1 point
-
This suggests to me that everything is set up ok from the apache side of things. Have you tried a fresh install of PW on this server to see if that goes ok? Maybe it will report what the problem is?1 point
-
I'd be happy to help. Can I take a look somewhere? You can PM me the login details. Don't know if I can make it today, but I can take a look tomorrow early in the morning before work or in the evening (Amsterdam timezone). I have a PW 2.4 with CKE 1.2.0 (default config) and have no problems. Have you tried other browsers? Have you installed any plugins in CKE? You also may want to switch the field to plain textarea and then back.1 point
-
Haven't experienced any problems with bxslider so maybe there's an other root of the evil. When I have troubles with HTML soup I prefer to check the syntax with the validator of W3C. Lot's of time it's just an non closed element or such.1 point
-
Ok just for the events usecase it is simple.....there should be no problem to make less intervalls since you have in the frontend output of the event a simple check. If you check the output of the event against the actual date there is no need to run the script to often since the site visitors don't see wrong content....and lets say once a day the script cleans older events out....some links: https://processwire.com/talk/topic/2448-show-date-published-on-a-page/#entry23246 https://processwire.com/talk/topic/24-publishunpublish-by-date-or-by-manual-means/#entry103 https://processwire.com/talk/topic/29-how-to-unpublish-a-page-without-deleting-it/ for the newsletter if no real experience for a good advice....1 point
-
<?php $site = $pages->get(SOMETHING); $image = $site->images->get("name=logo.jpg"); $image = $image->width(200); echo "<img src='$image->url'/>"; ?> But there's still no check whether the page or the image is acctually there.1 point
-
I don´t know what to tell you. I would use a foreach or an array with just several lines. Good luck1 point
-
Use a jpg compressor and move the slider until the point where the picture starts to look bad. Then move the slider a bit back. The eye can´t see the difference from the original but the size has become significant lesser. http://winsoftmagic.com/ajc.html1 point
-
The other approach you may want to look at is installing Virtualmin/Webmin to control everything from setting up virtuals with set packages to creating samba shares and so on.1 point
-
1 point
-
Some resources https://www.digitalocean.com/community/tutorials/how-to-set-up-apache-virtual-hosts-on-arch-linux https://wiki.archlinux.org/index.php/Apache_HTTP_Server http://www.tecmint.com/install-lamp-in-arch-linux/ https://www.linode.com/docs/websites/lamp/lamp-server-on-arch-linux1 point
-
Have you gone through the list on Nico's troubleshooting page? http://processwire.com/docs/tutorials/troubleshooting-guide/1 point
-
1 point
-
1 point
-
1 point
-
Hey people, look LOOK LOOOOOK at the latest commit on dev https://github.com/ryancramerdesign/ProcessWire/commit/36ec37d171672a1b786a554539cb5123b09117bc InputfieldPageTable now supports multiple templates for child items, so this is (at least for me) solving this issue. Hack away with you flexible page designs! :biggrin: CHEERS1 point
-
Table Use this for tabular data, like rate tables or other things that you might typically represent in a spreadsheet. Use it for situations where you don't need the full-blown flexibility of repeaters, as it's technically more efficient with far less overhead than repeaters. Something like the Events Fieldtype could be very easily re-created via a Table field, but the potential uses are far broader. But for the most part, think tabular data when it comes to the Table field. Multipliers This is good for when you need a range of values (whether text, textarea, numbers, dates, etc.). If you are using repeaters with just one field in them, you might be a lot better off with a Multiplier. Like the Table field, Multipliers are very efficient and low overhead relative to something like Repeaters. Use Multipliers when you need to repeat a single input multiple times, optionally with a min and max number of inputs. Lets say you are building an employee directory, and each employee has between 1 and 3 email addresses. Rather than using 3 separate email fields, you would use 1 multiplier field and specify min=1 and max=3. Repeaters These are infinitely flexible in terms of what they represent, but each row of values is technically a page in the system. As a result, with the flexibility comes significant overhead. This is really only an issue when the quantity of repeater items gets high, or when you have lots (thousands) of pages using repeaters. I recommend repeaters for setting up things like homepage carousels. For example, if you go to the Villas of Distinction homepage, there are 3 separate repeaters in use on that page, each holding a photo, title, description, link. The client can have as many items in each of those sections as they want. Currently it looks like the first repeater as 6 items, the 2nd has 2, and the 3rd has 6. The possibilities of what can be represented with repeaters is endless, but look for potential alternatives when dealing with large quantities (whether large quantities of repeater items, or large quantities of pages using repeaters). PageTable This is one of the ProFields that is available for free (thanks to Avoine sponsorship) on the ProcessWire dev branch. Meaning, it'll be available for everyone to use as part of the core in ProcessWire 2.5. And you can use it now if you don't mind running the dev branch. PageTable has all the flexibility of repeaters, but with lower overhead from the admin/input perspective. Rather than trying to bundle all the inputs on one screen, PageTable shows you a table of items and you click on the item to edit it in a modal window. This enables it to be a lot more efficient from the admin UI perspective. It's also more flexible than repeaters are in terms of where you store your items. PageTable lets you choose where they should live, whether as children of the page being edited, or as children of some other parent page you designate. They might be a little more work to setup than repeaters, but I think that most situations where you need the flexibility of repeaters may be better served by PageTable. PageTable still can't compete with the speed and efficiency of Table or Multiplier, but consider using PageTable anywhere that you might have used Repeaters before. Repeaters and PageTable are fundamentally different from the admin UI/input perspective, so you'd want to compare them yourself to see what suits your individual input needs better. PageTable involves more clicking to create and edit items, making Repeaters potentially faster for entering data rapidly. But PageTable will scale much further in the admin UI than Repeaters will, so I would personally favor PageTable in more situations than Repeaters.1 point
-
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/94938771 point
-
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.1 point
-
I'm not a fan of hard-coding id's, obviously for this purpose it's fine, but for app building, I use the config var in case the page id ever changes (if a new version of PW is released and the admin id is now 3, your code won't break). echo '<a href="'.$pages->get($config->adminRootPageID)->url.'">this way to the admin</a>';1 point
-
I would stick with PW, really I remember getting dizzy when I had to make pages in Drupal look the way I wanted: Where this margin is coming from? Ok, this module generates this HTML with 4 wrappers. Where it takes its css from? Let's see it has cached css-file which is generated every time I save module settings. Ok, let's take a look at its real css-file. Well, it's not really css-file, but css template written in php. Ok, what we see, it generates css depending on the options we set in module's properties, but I still can't see where this margin is set. I've spent already about 20 minutes trying to find this goddamn margin property. Ok, if it isn't here it should be somewhere else, let's dig through module's source files. Haveng spent another 10 minutes looking through module's source files I finally found this margin in module_name_API.php!!! WTF? Why put it here? Ok, I fixed my margin, but I have another page where this module's markup is output next to another's and now they overlay, because that another module generates its own markup and now I have to repeat this crazy procedure again for another module. No, not anymore! I have a lot of other things to do! Yes, Drupal is very powerful, but this continuos, never-ending hacking makes me suicidal I would rather spend time creating using the system then struggling with it. As for MODx, I really liked Evolution and still do, but PW makes it look unnecessary complex and is light years ahead in terms of intuitiveness and flexibility. I also tried to use Revolution, but to me it over-complicates things and I can't stand its sluggish back-end (thanks ExtJS). Their announcement IMO is pretty logical step to take as Revolution haven't equaled the hopes, but it gave really good understanding of what's really important for this CMS. I wish MODx team good luck with MODX3 because they've already made one of the best CMSs that I really like and just because they are great guys. Wish them to repeat their success with third version. Processwire brings joy to development, this is why I will keep using it It makes me learn and create rather then hack. And it has a brilliant community, in life of which I wish could participate much more then I do now.1 point
-
Ok, I tried to quote Ryan's post above, but accidentally modified it and overwrote with my own message. Ryan's code worked almost perfectly (it outputted sundays as their own row), so here is only minor changes to the original: <?php function renderCalendar($page, $year, $month, $field = 'startdate') { $year = (int) $year; $month = (int) $month; $startTime = strtotime("$year-$month-01 00:00:00"); $endTime = strtotime("+1 month", $startTime); // find all events that fall in the given month and year $events = $page->children("$field>=$startTime,$field<$endTime"); // get all the info you need to draw a grid calendar $weekDayNames = array('Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun'); $firstDayName = date('D', $startTime); // i.e. Tue $daysInMonth = date('t', $startTime); // 28 through 31 // make the calendar headline // $out = "<h1>" . date('F Y') . "</h1>"; // i.e. October 2011 // create the calendar header with weekday names $out .= "<table><thead><tr>"; foreach($weekDayNames as $name) $out .= "<th>$name</th>"; $out .= "</tr></thead><tbody><tr>"; // fill in blank days from last month till we get to first day in this month foreach($weekDayNames as $name) { if($name == $firstDayName) break; $out .= "<td> </td>"; } // draw the calendar for($day = 1; $day <= $daysInMonth; $day++) { // get the time info that we need for this day $startTime = strtotime("$year-$month-$day 00:00:00"); $endTime = strtotime("+1 day", $startTime); $dayName = date('D', $startTime); // if we're at the beginning of a week, start a new row if($day > 1 && $dayName == 'Mon') $out .= "<tr>"; // create the list of events for this day (if any) $list = ''; foreach($page->children("$field>=$startTime, $field<$endTime") as $event) { $list .= "<li><a href='{$event->url}'>{$event->title}</a></li>"; } // if any events were found for this day, wrap it in <ul> tag if($list) $list = "<ul>$list</ul>"; // make the day column with day number as header and event list as body $out .= "<td><h2>$day</h2>$list</td>"; // if last day in week, then close out the row if($dayName == 'Sun') $out .= "</tr>"; } // finish out the week with blank days for next month $key = array_search($dayName, $weekDayNames); while(isset($weekDayNames[++$key])) { $out .= "<td> </td>"; } // close the last row and table $out .= "</tr></tbody></table>"; // output the calendar return $out; }1 point
-
Here was Ryan's example code for calendar, until I (apeisa) modified it instead of quoting... I got the original back from my editor, I post it here as reference. Ryan - sorry I lost your message here. You wrote something about that it is fun to code calendars -apeisa <?php $year = (int) $input->urlSegment1; $month = (int) $input->urlSegment2; if(!$month) $month = date('n'); // if no month, use this month if(!$year) $year = date('Y'); // if no year, use this year $startTime = strtotime("$year-$month-01 00:00:00"); $endTime = strtotime("+1 month", $startTime); // find all events that fall in the given month and year $events = $page->children("date>=$startTime, date<$endTime"); // get all the info you need to draw a grid calendar $weekDayNames = array('Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun'); $firstDayName = date('D', $startTime); // i.e. Tue $daysInMonth = date('t', $startTime); // 28 through 31 // make the calendar headline $out = "<h1>" . date('F Y') . "</h1>"; // i.e. October 2011 // create the calendar header with weekday names $out .= "<table><thead><tr>"; foreach($weekDayNames as $name) $out .= "<th>$name</th>"; $out .= "</tr></thead><tbody><tr>"; // fill in blank days from last month till we get to first day in this month foreach($weekDayNames as $name) { if($name == $firstDayName) break; $out .= "<td> </td>"; } // draw the calendar for($day = 1; $day <= $daysInMonth; $day++) { // get the time info that we need for this day $startTime = strtotime("$year-$month-$day 00:00:00"); $endTime = strtotime("+1 day", $startTime); $dayName = date('D', $startTime); // if we're at the beginning of a week, start a new row if($day > 1 && $dayName == 'Sun') $out .= "<tr>"; // create the list of events for this day (if any) $list = ''; foreach($events->find("date>=$startTime, date<$endTime") as $event) { $list .= "<li><a href='{$event->url}'>{$event->title}</a></li>"; } // if any events were found for this day, wrap it in <ul> tag if($list) $list = "<ul>$list</ul>"; // make the day column with day number as header and event list as body $out .= "<td><h2>$day</h2>$list</td>"; // if last day in week, then close out the row if($dayName == 'Sun') $out .= "</tr>"; } // finish out the week with blank days for next month $key = array_search($dayName, $weekDayNames); while(isset($weekDayNames[++$key])) { $out .= "<td> </td>"; } // close the last row and table $out .= "</tr></tbody></table>"; // output the calendar echo $out;1 point