Jump to content

combicart

Members
  • Posts

    78
  • Joined

  • Last visited

Everything posted by combicart

  1. Hello, I'm currently creating an Events website. I've setup an 'events' page with a date, start time and end time. I'm using the fields to print them out on the page. However, I would like to add the option that visitors can download an ICS file so that they can quickly add the event to their calendar. I've found https://github.com/markuspoerschke/iCal for the creation of het actual ICS files. I've created a new template file (download-ics) and used one of the examples (https://github.com/markuspoerschke/iCal/blob/master/examples/example7.php) for the template. When i'm browsing to the url with the (download-ics) template the ICS file is being downloaded correctly. However now there are only fixed values inside the ICS file. How can I pass the variables from the actual event into the newly created (download-ics) template file so that the actual date and times can be used?
  2. I would also go for the Jumplinks module. One great feature is that you can mass upload a CSV file with all the pages that you would like to redirect. After that you can check how often the old link has been redirected to the new location and perhaps remove the redirect when it isn't being used anymore.
  3. Thanks Robin, that worked perfectly!
  4. Hello, I'm currently trying to implementing a store locator on my website (https://github.com/bjorn2404/jQuery-Store-Locator-Plugin). To render the stores on the map the stores are being loaded from an XML file. To geocode the locations, i've installed the Maps Marker from Ryan (http://modules.processwire.com/modules/fieldtype-map-marker/). So far so good, however now I'm stuck at generating the actual XML file. Especially in printing the individual stores in a foreach loop. For the XML file, i've take some inspiration from the sitemap.xml file The stores all have a template called 'location'. Can I just load those locations with $pages->find("template=location")? The code that I have so far: <?php function renderLocation(Page $page) { return "\n<marker " . "name=" . $page->title . "/>"; } function renderLocationsXML(array $locations = array()) { $out = '<?xml version="1.0" encoding="utf-8"?>'; $out .= '\n<markers>'; // Foreach loop? $out .= '\n</markers>'; return $out; } header("Content-Type: text/xml"); echo renderLocationXML; The XML file has to be in the following format <?xml version="1.0" encoding="utf-8"?> <markers> <marker name="Chipotle Minneapolis" lat="44.947464" lng="-93.320826" category="Restaurant" address="3040 Excelsior Blvd" address2="" city="Minneapolis" state="MN" postal="55416" country="US" phone="612-922-6662" email="info@chipotle.com" web="http://www.chipotle.com" hours1="Mon-Sun 11am-10pm" hours2="" hours3="" featured="" features="" /> <marker name="Chipotle St. Louis Park" lat="44.930810" lng="-93.347877" category="Restaurant" address="5480 Excelsior Blvd." address2="" city="St. Louis Park" state="MN" postal="55416" country="US" phone="952-922-1970" email="info@chipotle.com" web="http://www.chipotle.com" hours1="Mon-Sun 11am-10pm" hours2="" hours3="" featured="" features="Online Ordering " /> </markers> Could someone point in the right direction in how to create the function / foreach loop to generate the marker data / locations inside the XML file?
  5. Hi Doolin, I'm not really sure if I understand you correctly. But normally I just use an 'image field' set to '0' (no limit) for image galleries. You can use e.g. the description of the image for working with captions inside the gallery. With an foreach loop you can generate the markup that is needed for the image gallery.
  6. Hello Makari, When you would like to redirect an old url to a new url you need to include the complete url for the new location (including http://) E.g. Redirect 301 /old_path/old_sub_path http://www.newdomain.com/new_path/new_sub_path In general it's also a good practice to redirect users from the toplevel domain to it's www. variant (or the other way around. from www. to the toplevel domain). You can set this up with mod_rewrite. The example below will redirect users from domain.com to www.domain.com. RewriteEngine On RewriteCond %{HTTP_HOST} !^www\. [NC] RewriteRule ^ http://www.%{HTTP_HOST}%{REQUEST_URI} [L,R=301] One other way is to install one of the modules below to handle the redirects from inside ProcessWire: http://modules.processwire.com/modules/process-jumplinks/ http://modules.processwire.com/modules/process-redirects/
  7. Thanks for checking it out. Uploading images isn't the problem. At first the image is being added to the page correctly and everything is working. The problem arises the next day (I have the feeling it happens somewhere through the night) when the image is being removed. This only happens when uploading the image through CKEditor. When uploading images through the 'Media' page in the sidebar, the images aren't removed automatically. Yes indeed. That's indeed also the case. The image is added to the assets/files/[id of media library page] folder. Yes, that's also the case. In the page the id is used from the media library. The image is there after I uploaded it. There are two images (the original file and a thumbnail version). On the website, the following modules have been installed: - ProCache - Form Builder - Profields (Table) - MarkupSEO - MarkupSimpleNavigation - TextformatterGoogleMaps - TextformatterVideoEmbed - TextformatterSrcSet (but it's not enabled inside the body field where the images disappear) To be safe, i've added a screenshot of the settings that i've used for the body field. Might the 'HTML Options' have something to do with it? If you want I can give you temporarily access to the website.
  8. I've tested it in a bit more detail: - The uploaded image isn't present under site/assets/id. Both the original and the thumbnail image are gone - The image tag in the output is still present. It looks like <img alt="" src="/site/assets/files/[id]/[image].jpg" width="800"> - I'm currently using ProcessWire 3.0.11 If you need any additional information, please let me know.
  9. Thanks for this great module. When using the option to upload images with the media library in CKeditor (like you've mentioned in the previous post). Everything seems to be working fine. However when I visit the page the next day, the image is gone and it's also removed from the Mediamanager. However when uploading an image directly to the MediaManager (through the link in the sidebar) the images will be there the next day. Do you have an idea what's causing this?
  10. Thanks for the additional information, that helped me a lot in finding a solution. I will post the code below that i'm using for anyone that might want to achieve the same behavior: If statement at top of _main.php $sidebar_left = $pages->find("template=widget, widget_location.value=left"); $sidebar_left_count = 0; foreach($sidebar_left as $widgets) { if($page->is("$widgets->selector")) { $sidebar_left_count++; } } $sidebar_right = $pages->find("template=widget, widget_location.value=right"); $sidebar_right_count = 0; foreach($sidebar_right as $widgets) { if($page->is("$widgets->selector")) { $sidebar_right_count++; } } if($sidebar_right_count > 0 && $sidebar_left_count > 0) { $body_class = "two-columns"; } elseif($sidebar_right_count > 0) { $body_class = "sidebar-right"; } elseif($sidebar_left_count > 0) { $body_class = "sidebar-left"; } else { $body_class = "one-column"; } Set the class on the body element <body class="<?php echo $body_class; ?>"> Sidebar Left <?php if($sidebar_left_count > 0): ?> <aside class="sidebar-left"> <?php foreach($sidebar_left as $widget) { // check if the selector field is in use and if so, see if this page is supposed to display it: if( $widget->selector) { if( !$page->is("$widget->selector") ) continue; } $widgetType = $widget->widget_type->value; $widgetTemplate = file_exists("./partials/widget_{$widgetType}.php") ? "./partials/widget_{$widgetType}.php" : "./partials/widget_next_race.php"; include($widgetTemplate); } ?> </aside> <?php endif; ?> Sidebar Right <?php if($sidebar_right_count > 0): ?> <aside class="sidebar-right"> <?php foreach($sidebar_right as $widget) { // check if the selector field is in use and if so, see if this page is supposed to display it: if( $widget->selector) { if( !$page->is("$widget->selector") ) continue; } $widgetType = $widget->widget_type->value; $widgetTemplate = file_exists("./partials/widget_{$widgetType}.php") ? "./partials/widget_{$widgetType}.php" : "./partials/widget_next_race.php"; include($widgetTemplate); } ?> </aside> <?php endif; ?>
  11. @Macrura, thanks for your reply. I've tried multiple setups today, but unfortunately I can't seem to get it working. Ideally the body_class and the if statement for sidebars are adjusted based on the selector field. I currently have the following code inside my _main.php file. If statement at the top of the page to check if there is widget for sidebar left or sidebar right: $sidebar_left = $pages->find("template=widget, widget_location.value=left"); $sidebar_right = $pages->find("template=widget, widget_location.value=right"); if(count($sidebar_right) > 0 && count($sidebar_left) > 0) { $body_class = "two-columns"; } elseif(count($sidebar_right) > 0) { $body_class = "sidebar-right"; } elseif(count($sidebar_left) > 0) { $body_class = "sidebar-left"; } else { $body_class = "one-column"; } Setting the body class <body class="<?php echo $body_class; ?>"> Sidebar Left <?php if(count($sidebar_left)): ?> <aside class="sidebar-left"> <?php foreach($sidebar_left as $widget) { // check if the selector field is in use and if so, see if this page is supposed to display it: if( $widget->selector) { if( !$page->is("$widget->selector") ) continue; } $widgetType = $widget->widget_type->value; $widgetTemplate = file_exists("./partials/widget_{$widgetType}.php") ? "./partials/widget_{$widgetType}.php" : "./partials/widget_next_race.php"; include($widgetTemplate); echo $page->is("$widget->selector"); echo $widget->selector; } ?> </aside> <?php endif; ?> And Sidebar Right <?php if(count($sidebar_right)): ?> <aside class="sidebar-right"> <?php foreach($sidebar_right as $widget) { // check if the selector field is in use and if so, see if this page is supposed to display it: if( $widget->selector) { if( !$page->is("$widget->selector") ) continue; } $widgetType = $widget->widget_type->value; $widgetTemplate = file_exists("./partials/widget_{$widgetType}.php") ? "./partials/widget_{$widgetType}.php" : "./partials/widget_next_race.php"; include($widgetTemplate); echo $page->is("$widget->selector"); echo $widget->selector; } ?> </aside> <?php endif; ?>
  12. Many thanks for sharing this example. I've implemented this on my website, but i'm kinda stuck now. I've created an if statement to check if there are 0, 1 or 2 sidebars. With this if statement i'm changing the class on my body element so I can correctly style the page to display these sidebars. This is working till I set the 'selector' for a specific widget. If I set a widget to be displayed e.g. only on the homepage, the widget is displayed correctly. However on all the other pages, the class still prints out as if there is 1 sidebar. I've added my if statement below: $sidebar_left = $pages->find("template=widget, widget_location.value=left"); $sidebar_right = $pages->find("template=widget, widget_location.value=right"); if(count($sidebar_right) > 0 && count($sidebar_left) > 0) { $body_class = "two-columns"; } elseif(count($sidebar_right) > 0) { $body_class = "sidebar-right"; } elseif(count($sidebar_left) > 0) { $body_class = "sidebar-left"; } else { $body_class = "one-column"; } I've tried different versions, but those don't seem to work: find("template=widget, widget_location.value=left, selector!=") find("template=widget, widget_location.value=left, selector!=0") find("template=widget, widget_location.value=left, selector<0") Is there a way to check inside the find() method if the selector field is set or is there perhaps a better way to set the body class?
  13. Ok, thanks. I was under the impression to keep the number of fields as low as possible and reuse fields when possible. Will create separate image fields for each use case. Thanks!
  14. Hello, Currently when adding an image field, we can add a min. and max. image dimension for them. We also can overwrite some fields based on the template in which this field is used. Would it be possible to add the min. and max. image dimensions to those template overwrites? Currently when building a website I quite often use the image field to hold different 'types' of images. On e.g. the home page template this could be a hero image, and on the blog template this is a highlight image. In both templates, the images have different image dimensions. To make sure the image always looks crisp and to help the website editor, I always add a min. image width and hight for the image. Currently we need to add different image fields for those use cases, while they basically do the same thing. When we could set a template overwrite for these values, we can simply create 1 'image' field type and use it in multiple templates, with their own min. / max. image dimensions.
  15. Thanks Bernhard, wirerenderfile looks indeed like the function I was searching for! Will definitely try it out for the website i'm currently building
  16. Thanks, i've already read the tutorial, but will definitely take a look at the second link.
  17. Hello! I'm currently building my first website with Processwire. So far i'm really loving it, however i'm having a hard time wrapping my head around the delayed output in combination with separate partial files which are used for styling small parts of the website. I've seen this approach on the blog profile of Ryan and prefer this method where most of the markup resides inside small partial files instead of echoing the html markup inside the template file. I currently use the method below, but I'm not really sure if this is the best way to set this up. Perhaps someone uses this same setup or has a better approach? Would really love to hear your thoughts! This is my layout for the homepage. It consists of a title, a body text and a repeater field with 'widgets'. _main.php <article> <h1><?php echo $title; ?></h1> <?php echo $content; ?> </article> home.php function renderHomepageWidgets() { foreach($page->homepage_widget as $widget) { $page->homepage_widget; } $t = new TemplateFile(wire('config')->paths->templates . 'partials/homepage_widgets.php'); return $t->render(); } $content = $page->body . renderHomepageWidgets(); partials/homepage_widgets.php <?php if(count($page->homepage_widget)) : ?> <div class="homepage-widgets"> <?php foreach($page->homepage_widget as $widget) : ?> <div class="widget"> <picture> <!--[if IE 9]><video style="display: none;"><![endif]--> <source srcset="<?php echo $widget->homepage_widget_image->size(360, 200)->url; ?>, <?php echo $widget->homepage_widget_image->size(720, 400)->url; ?> 2x" media="(min-width: 1088px)" /> <source srcset="<?php echo $widget->homepage_widget_image->size(360, 200)->url; ?>, <?php echo $widget->homepage_widget_image->size(720, 400)->url; ?> 2x" media="(min-width: 860px)" /> <source srcset="<?php echo $widget->homepage_widget_image->size(250, 140)->url; ?>, <?php echo $widget->homepage_widget_image->size(500, 280)->url; ?> 2x" media="(min-width: 640px)" /> <!--[if IE 9]></video><![endif]--> <img srcset="<?php echo $widget->homepage_widget_image->size(360, 200)->url; ?>, <?php echo $widget->homepage_widget_image->size(720, 400)->url; ?> 2x" alt="<?php echo $widget->title; ?>" /> </picture> <div class="content"> <h3><?php echo $widget->title; ?></h3> <?php echo $widget->body; ?> <a href="<?php echo $widget->homepage_widget_url->url; ?>"><?php echo $widget->title; ?></a> </div> </div> <?php endforeach; ?> </div> <?php endif; ?>
×
×
  • Create New...