Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 06/11/2013 in all areas

  1. This one will refresh your css automatically every time it's updated (works only in a server environment): http://cssrefresh.frebsite.nl/
    4 points
  2. PS, Have a read of this to learn more about image fields: http://processwire.com/api/fieldtypes/images/
    3 points
  3. Also make sure that your template files are UTF-8 encoded.
    3 points
  4. You could also use php's trim function to remove whitespaces of a string: echo trim($categories);
    3 points
  5. first() or eq(0) for an array of (multiple) images, and leave it off if it's a single image. Single image: echo $page->main_image->getThumb('thumbnail'); Edit: adrian beat me to it =)
    2 points
  6. This is because it's set to be a single image field, so just don't use first() or eq(0). Or to make it a multi images field go to the the field settings / Details and set Maximum files allowed to 0 (infinite) or any number greater that 0.
    2 points
  7. what.i use this is good it does.work top {not buttock}, of htaccess u will.put it . enjoy <IfModule mod_expires.c> ExpiresActive On ExpiresDefault "access plus 1 seconds" ExpiresByType image/x-icon "access plus 1 year" ExpiresByType image/jpeg "access plus 1 year" ExpiresByType image/png "access plus 1 year" ExpiresByType image/gif "access plus 1 year" ExpiresByType text/css "access plus 1 month" ExpiresByType text/javascript "access plus 1 month" ExpiresByType application/octet-stream "access plus 1 month" ExpiresByType application/x-javascript "access plus 1 month" </IfModule> <IfModule mod_headers.c> <FilesMatch "\\.(ico|jpe?g|png|gif|swf|woff)$"> Header set Cache-Control "max-age=31536000, public" </FilesMatch> <FilesMatch "\\.(css)$"> Header set Cache-Control "max-age=2692000, public" </FilesMatch> <FilesMatch "\\.(js)$"> Header set Cache-Control "max-age=2692000, private" </FilesMatch> <FilesMatch "\.(js|css|xml|gz)$"> Header append Vary: Accept-Encoding </FilesMatch> Header unset ETag Header append Cache-Control "public" </IfModule> <IfModule mod_deflate.c> AddOutputFilter DEFLATE js css AddOutputFilterByType DEFLATE text/html text/plain text/xml application/xml BrowserMatch ^Mozilla/4 gzip-only-text/html BrowserMatch ^Mozilla/4\.0[678] no-gzip BrowserMatch \bMSIE !no-gzip !gzip-only-text/html </IfModule>
    2 points
  8. Rule of thumb: many things -> foreach one thing -> grab and echo directly In your case, if what you want is on another page echo $pages->get(123)->enlace; //123 is ID of that page You can also use path to that page instead of ID. Please have a look at the API documentation. Everything to get your started is explained there http://processwire.com/api/. Look at variables and selectors in the first instance. Edit: Quick addition for newbies - what Harmster wanted in the first post were the names and the values of Fields which is different from what gfdesign needs
    2 points
  9. Open thread for discussion about Vietnamese Translation/Language pack. Currently, the language pack is hosted on: https://github.com/xgenvn/processwire-vi_vn-translation
    2 points
  10. I noticed soemthing strange I don't think is very good. Add a date or email field to a template (ie basic-page). After filling the field on one page and looking at DB field table everything is ok, there's a new entry, the value is saved with the page id. Now if you remove the field from the template, you get prompted if you really want to, and after hitting ok, it shows messages for each page that uses this template that the field was deleted. So far so good. Now but you wouldn't expect that if you look at the field table, suddenly there's an empty entry for one and each page that has this template! Oops. And this empty data will stay there until you delete the field itself. It happens so far for date and the email field, for text field it seems ok. I use 2.3 dev (not nightly) and haven't tested in older versions.
    2 points
  11. Your questions above were more about structure of your HTML and CSS. You seem very new here to the ProcessWire forums, welcome I encourage you to learn more and follow these tutorials: http://wiki.processwire.com/index.php/Basic_Website_Tutorial http://wiki.processwire.com/index.php/Simple_News_System Also, you should dissect the default site profile to get a better understanding on how the API works. Then go the 'Site Profile' section of the Modules page and check out some of the profiles there. The 'Blog' and 'Skyscrapers' are incredibly cool! They will teach you some new methods of organizing your templates and how to call your page/pages data. VERY cool stuff! http://modules.processwire.com/categories/site-profile/ Welcome to the forums. We are glad to help you out, but you've got to help yourself first
    2 points
  12. Interesting post. The only ones I use are to test for responsive design on my pages. http://lab.maltewassermann.com/viewport-resizer/
    2 points
  13. http://www.w3fools.com/
    2 points
  14. Since you guys asked for it, I'll take a stab at a case study on the development process. Most of the development was done in about a week and a half. I started with the basic profile, but it ended up being something somewhat similar to the Blog profile in terms of how it's structured. Below I'll cover some details on the biggest parts of the project, which included data conversion, the template structure, the front-end development and anything else I can think of. Data Conversion from WordPress to ProcessWire One of the larger parts of the project was converting all of the data over from WordPress to ProcessWire. I wrote a conversion script so that we could re-import as many times as needed since new stories get added to cmscritic.com almost daily. In order to get the data out of WordPress, I queried the WordPress database directly (my local copy of it anyway) to extract what we needed from the tables wp_posts for the blog posts and pages, and then wp_terms, wp_term_relationships, and wp_term_taxonomy for the topics and tags. WordPress stores its TinyMCE text in a state that is something in between text and HTML, with the most obvious thing being that there are no <p> tags present in the wp_posts database. Rather than trying to figure out the full methodology behind that, I just included WP's wp-formatting.php file and ran the wpautop() function on the body text before inserting into ProcessWire. I know a lot of people have bad things to say about WordPress's architecture, but I must admit that the fact that I can just include a single file from WordPress's core without worrying about any other dependencies was a nice situation, at least in this case. In order to keep track of the WordPress pages imported into ProcessWire through repeat imports, I kept a "wpid" field in ProcessWire. That just held the WordPress post ID from the wp_posts table. That way, when importing, I could very easily tell if we needed to create a new page or modify an existing one. Another factor that had to be considered during import was that the site used a lot of "Hana code", which looked like [hana-code-insert name="something" /]. I solved this by making our own version of the Hanna code module, which was posted earlier this week. Here's an abbreviated look at how to import posts from WordPress to ProcessWire: $wpdb = new PDO("mysql:dbname=wp_cmscritic;host=localhost", "root", "root", array(PDO::MYSQL_ATTR_INIT_COMMAND => "SET NAMES 'UTF8'")); $posts = wire('pages')->get('/posts/'); $sql = " SELECT * FROM wp_posts WHERE post_type='post' AND post_status='publish' ORDER BY post_date "; $query = $wpdb->prepare($sql); $query->execute(); while($row = $query->fetch(PDO::FETCH_ASSOC)) { $post = $posts->child("wpid=$row[ID]"); // do we already have this post? if(!$post->id) { // create a new post $post = new Page(); $post->template = 'post'; $post->parent = $posts; echo "Creating new post...\n"; } $post->of(false); $post->name = wire('sanitizer')->pageName($row['post_name']); $post->title = $row['post_title']; $post->date = $row['post_date']; $post->summary = $row['post_excerpt']; $post->wpid = $row['ID']; // assign the bodycopy after adding <p> tags // the wpautop() function is from WordPress /wp-includes/wp-formatting.php $post->body = wpautop($row['post_content']); $post->save(); echo "Saved post: $post->path\n"; } What I've left out here is the importing of images, topics, tags, and setting the correct authors for each post. If anyone is interested, I'll be happy to go more in depth on that, but didn't want to overwhelm this message with code. Template File Structure This site makes use of the $config->prependTemplateFile to automatically include the file _init.php before rendering a template file, and $config->appendTemplateFile to automatically include the file _main.php after. So the /site/config.php has this: $config->prependTemplateFile = '_init.php'; $config->appendTemplateFile = '_main.php'; You may recognize this as being the same setup from the Skyscrapers profile. The _init.php includes files containing functions we want to be available to all of our templates, and set default values for the regions we populate: /site/templates/_init.php /** * Include function and hook definition files * */ require_once("./includes/render.php"); require_once("./includes/hooks.php"); /** * Initialize variables populated by templates that get output in _main.php * */ $browserTitle = $page->get('browser_title|title'); $body = "<h1>" . $page->get('headline|title') . "</h1>" . $page->body; $side = ''; $renderMain = true; // whether to include the _main.php file The includes/render.php file that is included above includes several functions for generating markup of navigation and post summaries, or any other shared markup generation functions. Examples are renderPost(), renderNav(), renderTags(). This is similar to the blog.inc file from the Blog profile except that I'm letting these functions generate and return their own markup rather than splitting them into separate view files. I personally find this easier to maintain even if it's not as MVC. The includes/hooks.php sets up any hooks I want to be present for all of my templates. I could have also done this with an autoload module, but found this to just be a little simpler since my hooks were only needed on the front-end. The main hook of interest is one that makes all posts look like they live off the root "/" level rather than "/posts/" (where they actually live). This was in order to keep consistency with the URLs as they were in WordPress, so that the new site would have all the same URL as the old site, without the need for 301 redirects. /site/templates/includes/hooks.php /** * This hook modifies the default behavior of the Page::path function (and thereby Page::url) * * The primary purpose is to redefine blog posts to be accessed at a URL off the root level * rather than under /posts/ (where they actually live). * */ wire()->addHookBefore('Page::path', function($event) { $page = $event->object; if($page->template == 'post') { // ensure that pages with template 'post' live off the root rather than '/posts/' $event->replace = true; $event->return = "/$page->name/"; } }); Our /site/templates/_main.php contains the entire markup for the overall template used site wide, from <html> to </html>. It outputs those variables we defined in _init.php in the right places. For example, $body gets output in the <div id='bodycopy'>, $side gets output in the right <aside>, and $browserTitle gets output in the <title> tag. /site/templates/_main.php <?php if($renderMain): ?> <html> <head> <title><?=$browserTitle?></title> </head> <body> <div id='masthead'> // ... </div> <div id='content'> <div id='bodycopy'><?=$body?></div> <aside id='sidebar'><?=$side?></aside> </div> <footer> // ... </footer> </body> </html> <?php endif; ?> We use the rest of the site's template files to simply populate those $body, $side and $browserTitle variables with the contents of the page. As an example, this is an abbreviated version of the /site/templates/post.php template: /site/templates/post.php // functions from /site/templates/includes/render.php $meta = renderMeta($page); $tags = renderTags($page); $authorBox = renderAuthor($page->createdUser); $comments = renderComments($page); $body = " <article class='post post-full'> <header> <h1>$page->title</h1> $meta </header> $page->body $tags $authorBox $comments </article> "; if(count($page->related)) { $side = "<h4>Related Stories</h4>" . renderNav($page->related); } What might also be of interest is the homepage template, as it handles the other part of routing of post URLs since they are living off the root rather than in /posts/. That means the homepage is what is triggering the render of each post: /site/templates/home.php if(strlen($input->urlSegment2)) { // we only accept 1 URL segment here, so 404 if there are any more throw new Wire404Exception(); } else if(strlen($input->urlSegment1)) { // render the blog post named in urlSegment1 $name = $sanitizer->pageName($input->urlSegment1); $post = $pages->get("/posts/")->child("name=$name"); if($post->id) echo $post->render(); else throw new Wire404Exception(); // tell _main.php not to include itself after this $renderMain = false; } else { // regular homepage output $limit = 7; // number of posts to render per page $posts = $pages->find("parent=/posts/, limit=$limit, sort=-date"); $body = renderPosts($posts); } The rest of the site's template files were handled in the same way. Though most were a little simpler than this. Several were simply blank, since the default values populated in _init.php were all that some needed. Front-end development using Foundation 4 The front-end was developed with the Foundation 4 CSS framework. I started with the Foundation blog template and then tweaked the markup and css till I had something that I thought was workable. Then Mike and I sent the _main.php template file back and forth a few times, tweaking and changing it further. There was no formal design process here. It was kind of a photoshop tennis (but in markup and CSS) where we collaborated on it equally, but all under Mike's direction. After a day or two of collaboration, I think we both felt like we had something that was very good for the reader, even if it didn't originate from a design in Photoshop or some other tool like that. I think it helps a lot that Foundation provides a great starting point and lends itself well to fine tuning it the way you want it. I also felt that the mobile-first methodology worked particularly well here. Comments System using Disqus We converted the comments system over to Disqus while the site was still running WordPress. This was done for a few reasons: Disqus comments provide one of the best experiences for the user, in my opinion. They also are platform agnostic, in that we could convert the whole site from WP to PW and not have to change a thing about the comments… no data conversion or importing necessary. Lastly, ProcessWire's built-in comments system is not quite as powerful as WordPress's yet, so I wanted cmscritic.com to get an upgrade in that area rather than anything else, and Disqus is definitely an upgrade from WP's comments. In order to ensure that Disqus could recognize the relations of comment threads to posts, we again made use of that $page->wpid variable that keeps the original WordPress ID, and also relates to the ID used by the Disqus comments. This is only for posts that originated in WordPress, as new posts use a ProcessWire-specific ID.
    1 point
  15. I just pushed ProcessWire v2.3.1 to the dev branch. This is a fairly major change in that it switches the DB driver from mysqli to PDO. It meant changes to a large percentage of core files. ProcessWire still supports mysqli, but doesn't attempt to use it unless a module or a template asks for it via the $db API variable. The new API variable (for the PDO driver) is $database. More about PDO at php.net If you are using the dev branch, be careful and test thoroughly with this latest commit to it. Before upgrading, you may want to double check that your PHP supports PDO by looking at your phpinfo (CMD-F or CTRL-F for "PDO"), especially if you are running PHP 5.2.x (where PDO wasn't compiled in by default). Though if you are running PHP 5.2 (vs 5.3.8+) then you may want to just stick with ProcessWire 2.3.0 and upgrade your PHP version when possible. If you are using any modules that use the procedural version of mysqli functions (vs. the $this->db object oriented versions), or type-hint mysqli in methods, then those modules will no longer work. If you come across any modules that don't work with 2.3.1, please let me know here so that I can assist the author in updating them. Note that FormBuilder is one of the modules that does not work with 2.3.1, but I have posted an update in the FormBuilder board that corrects it–so be sure to download that version if you are tracking the dev branch of ProcessWire and using FormBuilder. What this new version adds: 1. New API variable $database that refers to the PDO database. The old $db API variable is still there and refers to mysqli for any modules that continue to use it. 2. New API variable $log that lets you easily log messages or errors to the system logs. Usage: $log->message("This saves this line to messages.txt"); $log->error("This saves this line to to errors.txt"); $log->save("my-log", "This saves this line to my-log.txt"); // Get an array of the last few entries saved to the messages log $entries = $log->get('messages'); // Get an array of the last 50 entries saved to my-log $entries = $log->get('my-log', 50); Note that as always, log files are located in /site/assets/logs/. 3. Conditional autoload modules. In PHP 5.3+, modules may now specify an anonymous function OR a selector string, rather than a boolean for the 'autoload' property returned by getModuleInfo(). PW runs the anonymous function after determining the current $page, so your module can make autoload decisions based on the $page (or any other factor you'd like), if desired. Lets say that we have a module that we only want to autoload when the template is 'admin': public static function getModuleInfo() { return array( 'title' => 'Module Title', 'summary' => 'Summary text...', 'version' => 1, 'autoload' => function() { if(wire('page')->template == 'admin') return true; else return false; }); } And the same example but using a selector for autoload: public static function getModuleInfo() { return array( 'title' => 'Module Title', 'summary' => 'Summary text...', 'version' => 1, 'autoload' => 'template=admin' ); } 4. Addition of $pages->add() method. Actually $pages->add($template, $parent, [string $name], [array $values]); This function adds a new page to the database and returns it. This is for syntax convenience, but using the old method is still perfectly fine too. Here's a few examples of usage: // add a new page using template basic-page under /about/ $newpage = $pages->add('basic-page', '/about/'); // same as above, but named 'contact' $newpage = $pages->add('basic-page', '/about/', 'contact'); // same, but populate the title field too $newpage = $pages->add('basic-page', '/about/', 'contact', array('title' => 'Contact Us')); // you can also do this, specifying the values array as 3rd argument: $newpage = $pages->add('basic-page', '/about/', array('title' => 'Contact Us')); $template and $parent are required, but may be objects, IDs, or string identifiers (like name for template, or path for page). When you add a new page and don't specify a 'name', then PW will make one up, guaranteed to be unique. 5. Module files that end in '.module.php' are now supported. So rather than ClassName.module, you may use ClassName.module.php if you prefer it. The purpose here is to support text editors that determine their syntax highlighting based on the file extension. More updates being made almost daily. Please report any issues you experience. Thanks, Ryan
    1 point
  16. Hi, There's not much to this one. It doesn't stretch the limits of PW at all but the client is very happy with how easy it is to edit content. http://walkerabercrombie.com.au/ This is my first PW site (I usually use either textpattern & ExpressionEngine) and it was an absolute joy to learn something new. Illustrations by the great: http://lewkeilar.com/ Regards Martin
    1 point
  17. Guys, many thank for the patience. Very appreciated. I already got it. Sorry for many questions as well. My respects
    1 point
  18. As Ozwim eluded to: $page->main_image->getThumb('thumbnail');
    1 point
  19. thumbnail in this case is the name you reference in the template. The first() method selects the first image in the list of images attached to the page. $page->main_image->first()->getThumb('thumbnail'); if it is "portait-small,300,500" it woud be $page->main_image->first()->getThumb('portrait-small');
    1 point
  20. This should do it. Replace eq(0) with the number of the image in the main_image field. echo $page->main_image->eq(0)->getThumb('thumbnail');
    1 point
  21. I use and love HamsterPlayGround it is small and lightwight and use own scripts that let you do everything you can think of with mails: PlayGround But if you don't want play, only need one quick up and ready, you may look here: http://www.janaserver.de/start.php?lang=en JanaServer comes with HTTP, HTTPS, Proxy, SMTP, POP3, IMAP, DNS servers, but you can configure it to run none, one or any number of them. Not fancy but stable.
    1 point
  22. EASY may not always be BEST sometimes ya gotta get a little more dirty and involved with more code to get something to work. It took me many hours of testing this and that, and I finally have a CSS drop menu that works with my nested unordered lists. I don't know much about PHP, but everything I have learned has been because PW uses it to display data.
    1 point
  23. You can also see it in the URL when editing the page . Or echo echo $page->id; in your template file when developing . Of course, delete code when done
    1 point
  24. Hi, look here: http://processwire.com/talk/topic/3244-image-orientation-on-upload/#entry32333 and above
    1 point
  25. Hi Marco, Your field 'img_evento' holds multiple images. To output them, you need another loop: if (count($event->img_evento)) { echo '<ol class="thumb-grid group">'; foreach ($event->img_evento as $image) { echo '<li><a href="#"><img src="'.$image->url.'" alt="'.$image->description.'" /></a></li>'; } echo '</ol>'; You can also create thumbnails inside the loop if your images need to be smaller.
    1 point
  26. Thanks Soma, I confirmed the issue, at least in 2.3.1 and fixed it yesterday. I'm not exactly sure when it was introduced, but it's possible it's been there for a couple of major versions. The entries were getting deleted as they should, but then inserted again when the $page->save(); occurred within the same function. The thing that I'm not yet sure about is why i had a $page->save(); in there, which doesn't seem necessary. But there must have been a reason for it, which escapes me so far. So I've left it there commented out to examine further.
    1 point
  27. I've been using Susy for some small personal projects and once you get the hang of it every other framework feels like a bloat. Their adagium is: Your markup. Your design. Our math. Sound familiair?
    1 point
  28. 960.gs was the one that really kicked in then back in the days - for me and many others. I liked it so much that when I decided that we need to build our own fluid grid system, it had to be based on 960 syntax and be fully compatible with ancestor. BFluid was born. Since then it's been my one and only choise for css grid. Why to build own css grid when world is full of them? Simple - they don't bend the way you want. Most are based on fixed column count and don't support gutter + padding in cells. I also hate to have axtra markup for every row or extra class names for first/last items. BFluid is build on LESS so you can create custom grids on the fly. And have as many or as little of columns as you need - with gutter and padding. Nesting, multiple grids, fixed grid, semantic markup - it's all there. All we would need is some spare time to build cool site for it - or at least decent documentation. Maybe this summer..
    1 point
  29. Diogo, Small typo: $config->url->templates should be $config->urls->templates - you are missing the "s"
    1 point
  30. Kube is indeed nice, but doesn't support IE7 either. Also less is not my favourite preprocessor. A nice overview is this site: http://usablica.github.io/front-end-frameworks/compare.html
    1 point
  31. Shouldnt it be $config->urls->templates ...? Path is for php and file system.
    1 point
  32. Have you seen this thread: http://processwire.com/talk/topic/3392-emulate-natsort/ The code I mention in the last post worked well for me.
    1 point
  33. This is why I'm currently working on a Processwire site profile based on unsemantic grid system. It claims itself the successor to the 960 grid system and promises backwards compatibility down to IE 7. My site profile still needs a little polishing but I'll than make it public on Github. Hope to have it ready by the end of this week. You can see a preview here.
    1 point
  34. Here is another one, more CSS oriented! Demo: http://leaverou.github.io/CSSS/#intro Download: https://github.com/LeaVerou/csss Website: http://lea.verou.me/2010/10/my-ft2010-slides-and-csss-my-presentation-framework/
    1 point
  35. It is technically possible to do all of this in ProcessWire and more, but since some of your needs are unique it would involve writing some functionality yourself. For some of your needs there is likely code available here on the forums which I'm sure someone will point you too soon (I'm typing on mobile), and for everything else the community is here to help you out. The thing with ProcessWire is that almost anything is possible, but I have to ask have you taken a look at the tutorials and familiarised yourself with some of the docs on the website to get a feel for how the system works? At some point early on you will be creating fields and templates to accomplish a lot of this. Of course if you like you could also add your requirements to the Jobs forum and it is possible someone could develop this for you, but it is always good to get stuck in and get a better understanding of the system first if you have the time.
    1 point
  36. Try http://novasiria.it/en or http://novasiria.it/en/ and got same result (works), like http://novasiria.it/en/http404 or http://novasiria.it/en/http404/ (works). Same thing for test example url (error). Without the switch language menu all works well, and with test or test/ we got the 404 error page. Error notifies are sent for any image not found (just for test), when crawler bot runs or when we call a not existent page.
    1 point
  37. When calling a page url without trailing slash.
    1 point
  38. hmm, the most links in the first post are really old? Think today it's mandatory to build a site responsive. Made my first two (small) responsive projects with Kube. Easy to understand and use. Nice documentation. Not so bloated like the big ones. Also there are two demo site to learn from. Locally I'm just playing around with Pure. Also a nice slim framework. For me a small framework like Kube or Pure is really helpful. Like OF said: no need to reinvent the wheel. BTW: this thread should be better placed under 'Dev Talk' (no PW topic..)?
    1 point
  39. I feel like a padawan learning from Yoda.. ;P #lamestarwarsreferenceforthewin
    1 point
  40. Just in case there is anyone else who needs to search comments. I pieced together some stuff Soma and Ryan had posted in other topics. Here is a DB query workaround: $query = $db->query("SELECT pages_id FROM field_comments WHERE data LIKE '%SomeStringHere%' ORDER BY created"); $ids = array(); while($row = $query->fetch_row()) $ids[] = $row[0]; $results = $pages->getById($ids);
    1 point
  41. Batcher has saved me major time on a few occasions too. Definitely a must-have module.
    1 point
  42. Thanks Wanze, Was hoping there was a PW way. I ended up using the following: $images = $page->$image_field->getArray(); natsort($images); $reversed_images = array_reverse($images); $sortedImages = new WireArray(); $sortedImages->import($reversed_images); $page->$image_field = $sortedImages; I had to reverse the array, I am guessing because of the way import brings them in, so that they are in the correct ascending order. After the final line I make a few more changes to the $page and then save it. Anyway, this seems to work fine.
    1 point
  43. Grays I went through the same cycle as you and in case it helps at all all I will say is that using the default site that PW comes with and reading this forum and the links the others here have posted gradually got my PHP+PW engine started and even though it's only a low capacity engine (to stretch a metaphor) it is a very happy and productive one. That is to say I am *extremely* glad I found and persevered with PW and PHP because with the help of the generous people here and the great product PW is, I have been able to fly up and away from my old 'stuck' CMS to where I am now where I feel I could tackle almost anything with a little planning and QnA on the forum. So I'm sorry this post of mine won't help you practically but I hope it helps you feel that you will be able to do as I have (and likely more and better) and end up having a superb tool in your tool belt for future website work.
    1 point
  44. Well it is all about variable scope. None of the PW variables (http://processwire.com/api/variables/) are available inside a php function. So you can use the wire function for any of those PW variables inside a function. If you're going to be using a variable more than once inside the function, it can be worth doing this at the top of the function: $input = wire('input'); and for any other PW variables you might need access to.
    1 point
  45. So I have a simple question. I am doing something very wrong I guess, I have two issues. Issue 1. When I go to hover over the thumbnail in the images field, it breaks. Not really sure what is going on here, but I can live with this issue. (found solution to this one.) Issue 2. I can't figure out how to pull the thumbnails, if they exist into my template. I am currently using this: <ul class='gallery'> <?php foreach($page->images as $image) { $thumb = $image->size(500, 400); echo "<li class='gallery-item'>"; echo "<a href='{$image->url}' class='albumImageLinks fancybox-button' rel='fancybox-button'>"; echo "<img class='gallery-image' src='{$thumb->url}' alt='{$thumb->description}' /></a>"; echo "</li>"; } ?> </ul> However, I want to pull a thumbnail if it exist for certain images which I need to crop using your module. I have tried everything in the directions, but I keep getting errors involving eq. Sorry I am not the best at php. ------------------------------------------------ Solved my problem: for people in the future here is the code that worked for me: <ul class='gallery'> <?php foreach($page->port_images as $image) { $thumb = $image->getThumb('thumbnail'); echo "<li class='gallery-item'>"; echo "<a href='{$image->url}' class='albumImageLinks fancybox-button' rel='fancybox-button'>"; echo "<img class='gallery-image' src='{$thumb}' /></a>"; echo "</li>"; } ?> </ul> Also you need to create a thumbnail settings that matches what you were going to use for the size parameters. For me I was using 500/400, if you describe these settings, they are defaulted, then you can crop to the size you need for specific pictures, the rest are center cropped, which is exactly what I needed! Thanks for this fantastic solution for cropping images!
    1 point
  46. Hi and welcome! First thing would be checking if you have mod_rewrite enabled, but if you didn't get that error during the install, it must be. Second thing would be changing the Apache directive AllowOverride from None to All http://httpd.apache.org/docs/2.2/mod/core.html#allowoverride. The file where you have to do this depends on the operative system.
    1 point
  47. For the other part of it, in preventing the duplicates. As mentioned before, the pages you retrieve are already going to be unique. But like you said, you may have duplicate field values even among unique pages. Lets say that you wanted to guarantee the uniqueness of a 'title' field, for example: $uniqueResults = array(); foreach($results as $resultPage) { $uniqueResults[$resultPage->title] = $resultPage; } Following that, there will be no pages with duplicate titles in your $uniqueResults array. You can take the same approach with any other field(s). Though make sure your field resolves to a string before using it as a key in your $uniqueResults array.
    1 point
×
×
  • Create New...