Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 06/01/2015 in all areas

  1. Today I can finally share a project with you, that started about two years ago. Together with a colleague (the daughter of the client) I did the concept and design and a click-dummy for a course of my studies. Half a year later after finishing my studies we then did some clean-up and I programmed it in ProcessWire. And now nearly a year later all the content—texts, photos and a lots of tech. information—is ready, too, so it can soft-launch on monday. http://korona-licht.de/ The client is a small local company selling mostly LED lighting. They've a handful of quite flexible systems to build on, which can be adapted to a lot of use cases, as well as the ability to custom build things if needed. While they're not a very big company their portfolio has lot's of great national and even some international projects to offer. It was a really nice experience working with them and I'm really happy that even things like well written texts have finally found it's way into the website. Others may have just published it halfway through the project.
    2 points
  2. @peter For the title you can specify a pattern to force the pdf extension. ^.*\.pdf$
    2 points
  3. Your ping comparison is flawed as 50 requests wouldn't lead to 2sec difference. 50 request with 45ms difference would result in about this: 45ms (initial request) 45ms * 49/4 (about 4 concurrent connections to single domain) ----- 596.25 ms So the 45ms add up to about half a second, depending on server/browser. And 50 requests is not really a small number in that regard. Throw in a second domain – own or external cdn or even simply a second subdomain to the same site – and you'll get double the concurrent requests.
    2 points
  4. ok found the missing thing...deeper look in your html shows: <a href="#"> <img src="unfallservice.png"> </a> so the imagename is there....not the path/url...so it was wrong example from me...since i load the image always in a var like: //get the first image from the array of the repeater field $myimage = $col->images->first(); and then use it like: //use the $myimage var to call all needed things like url, name, description... <a href="#"> <img src="<?php echo $myimage->url; ?>" alt="<?php echo $myimage->description; ?>" /> </a> you can set the size, too with this API calls have a good read here: https://processwire.com/api/fieldtypes/images/ there is my example, too for a fast look you could quick change: <a href="#"> <img src="<?php echo $col->images->first(); ?>" /> </a> //to <a href="#"> <img src="<?php echo $col->images->first()->url; ?>" /> </a> best regards mr-fan
    2 points
  5. Working on a site at the moment with lots of PDF downloads and was wondering how you handle these? In my ProcessWire projects so far, each PDF has generally be restricted to a single page. I normally create a field called Files and reference that in any CK Editor links. The problem I realised is that when one of these PDFs needs replacing, my client needs to remember every page where the PDF is referenced. With this site I'm currently building, I have multiple pages referencing the same PDF(s). In the CK Editor modal for linking files, I can of course choose a different page where the file "lives". I'm starting to wonder though if I should create a virtual Files directory which would simply be a container page with each sub-page representing and named after a file. This way, when my editors need to replace a file, they just need to replace and update in a single location. Any known cons of doing it this way?
    1 point
  6. Love ListerPro. Will definitely use it and it would allow me to use columns for last updated, modified by and even short descriptions of files etc
    1 point
  7. Looks fine to me ! And take a look at Soma's site. He has a post on flexible downloads
    1 point
  8. Does the following recipe help? Change homepage’s default language
    1 point
  9. i see it works now...glad you get it! PW is great - the API is easy and flexible - if you dig deeper as easier is will be also recommend the google forum search (the forum search isn't that good) : https://processwire.com/talk/topic/6196-easy-search-on-pw-forums-with-google/?p=60632
    1 point
  10. Guys - you're right. Problem at my end with my list items and formatting didn't help.
    1 point
  11. To answer your last question, you can create whole new admin interfaces using the API with some work, however if you're in a hurry you can use ListerPro (single license is really cheap) to create your own admin pages with filtering capabilities. Depends how much code you want to write really
    1 point
  12. Welcome to processwire! No problem you should read about the difference that your title field is a "field" and your image field is a "array" of images/files... so try with: div class="container-fluid"> <div class="row"> <? foreach ($page->columns as $col):?> <div class="col-sm-3 img-responsive"> // get the very first image from images list since image field is accepting multiple images (unless you change the value of `Maximum files allowed` under Fields > images > Details tab > Maximum files allowed). <a href="#"> <img src="<?php echo $col->images->first(); ?>" /> </a> <div class="test"><a href="#"><?=$col->title; ?> </a></div> </div> <? endforeach; ?> </div> </div> edit: BernhardB beat me....
    1 point
  13. <a href="#"> <img src="<?php echo $col->images; ?>" /> </a> should be something like <a href="#"> <img src="<?php echo $col->image->url; ?>" /> </a> attention: you can set up image fields to have ONE ore MULTIPLE images in it. if you set the max number to ONE, then the example above will work. if you set it to multiple files, you would need something like this: foreach($col->images as $img) { echo '<a href="#"> <img src="' . $img->url . '" /> </a>'; } welcome to processwire and the forum happy processwiring!
    1 point
  14. There should be no Problem: Quote from soma page 16: Yes you can. 'parent_class' => 'active', // string (default 'parent') overwrite class name for current parent levels
    1 point
  15. Is not it the "parent_class" option?
    1 point
  16. PageTable would fit better here since you can use different templates and fields for output... there is even a exented module for this to get the output rendered nice in the backend... https://processwire.com/talk/topic/7459-module-pagetableextended/ good example how to use it: https://processwire.com/talk/topic/7459-module-pagetableextended/#entry71972 regards mr-fan
    1 point
  17. Hi, Did you find a solution to your problem, and what was it? Have a nice weekend!
    1 point
  18. Hello, Not sure I can help, and I don't know what you've already tried, but: Have you read, for example, https://github.com/ryancramerdesign/ProcessWire#resolving-an-apache-500-error and/or http://processwire.com/docs/tutorials/troubleshooting-guide/ In site/config.php, have you customized this: /** * Installer: HTTP Hosts Whitelist * */ $config->httpHosts = array('localhost', 'subdomain.name.tld/subdirectory/', 'othersubdomain.name.tld/'); Or this in .htaccess: # ----------------------------------------------------------------------------------------------- # OPTIONAL: Set a rewrite base if rewrites aren't working properly on your server. # And if your site directory starts with a "~" you will most likely have to use this. # ----------------------------------------------------------------------------------------------- # RewriteBase / # RewriteBase /pw/ # RewriteBase /~user/
    1 point
  19. Today I've created a really simple little module that is configurable and attaches to hooks. So it has more or less everything of a real world module in it. I thought processwire beginners would be interested in reading how to create such a module so I added some comments to the source code in a way the module should explain itself... Here it is: /** * BackgroundChanger module for demonstration purposes * * Demonstrates the Module interface and how to add hooks in a more real world manner... * * ProcessWire 2.x * Copyright (C) 2014 by Domenic Helfenstein * */ class BackgroundChanger extends WireData implements Module, ConfigurableModule { public static function getModuleInfo() { return array( /* * the __("text") methods are used for multilanguage support * see: https://processwire.com/api/multi-language-support/code-i18n/ */ 'title' => __('BackgroundChanger'), 'summary' => __('This is a simple real world module that can change the background color.'), 'version' => 105, /* * autoload must be true if the module depends on hooks * see: http://wiki.processwire.com/index.php/Module_Creation#Details_of_what_the_.22autoload.22_property_means */ 'autoload' => true, /* * it is wise to run modules in singular mode when using hooks * see: http://wiki.processwire.com/index.php/Module_Creation#Details_of_what_the_.22singular.22_property_means */ 'singular' => true, ); } public function __construct() { //set default values $this->backgroundColor = 'yellow'; /* * !!! the value in the db will be automatically injected into this var * because it is named equal to the value of $field->name in * getModuleConfigInputfields !!! */ } public function init() { // add a hook after each page is rendered and modify the output $this->addHookAfter('Page::render', $this, 'changeBackground'); } public function changeBackground($event) { $page = $event->object; //do only modify non-admin pages if($page->template == 'admin') return; $extension = <<< _OUT <style> body {background-color:{$this->backgroundColor};} </style> _OUT; $event->return = str_replace("</head>", $extension."</head>", $event->return); } public static function getModuleConfigInputfields(array $data) { //create a fieldset $inputfields = new InputfieldWrapper(); //create field for background color $field = wire('modules')->get('InputfieldText'); $field->name = 'backgroundColor'; $field->label = __("Enter the hex-code or name of the desired background color. (visit colorpicker.com)"); //if there is already a value stored, set this value to the field if(isset($data['backgroundColor'])) $field->value = $data['backgroundColor']; //add the field to the fieldset $inputfields->add($field); //return the fieldset to display return $inputfields; } } I hope this helps others creating their own modules! BackgroundChanger.module
    1 point
  20. Disclaimer This is not a step by step tutorial, but the script posted serves as an example of how easy it is to bootstrap ProcessWire(PW), query an external API (in this case, Strava) and import stuff into PW pages using the PW API. To the import! So i wanted a quick, easy and automated way to import someones Strava activities into his/her own 'activity feed' on a certain PW website. Strava has an API which you can use to -amongst other things- get your own activity data. After setting up my Strava app i had access to the API. Next step was to import the JSON data i wanted into PW pages. This was as easy as creating a PW bootstrapped script (see code below) and using the PW API to import the data into Pages. For convenience in talking to the Strava API i used a library that is available on Github. To keep track of what was happening i decided it would be nice to log the import results to a log file. Luckily, PW had me covered by using the WireLog class (/wire/core/WireLog.php). Result With some googling on Strava and a (very) basic knowledge of PHP and the PW API i was able to get things working in no-time. With no other CMS i've worked with -and i've had dealings with quite a few- it would have been so easy to get the desired result. Some notes about the script: PW version used: 2.4.12, but should work in earlier versions as well. It does not create templates, fields and pages for you. If you would want to use it (maybe as a starting point), create templates, fields and pages for your own needs and adjust the script accordingly. Also remember to adjust script paths. In the posted example i don't do any sanitizing on the Strava data. You maybe should In production you would maybe call these kind of importers via a cronjob, and make it non-accessible from the outside. It served my purposes. There might be better ways of handling this stuff. All suggestions and/or questions are welcome. In this case the script was/is called importer_strava.php , located at mydomain/importer/importer_strava.php and requested manually. See notes above, number 3. <?php /** * Strava Importer * * This crude script will import your own Strava activities into newly created * PW pages under a given parent page. The import result will be logged in: * /site/assets/logs/importer_strava.txt, using the WireLog class. * * For this to work you first need to create an app via http://www.strava.com/developers * Strava API reference: http://strava.github.io/api/ * * The PHP library used for working with the Strava v3 API can be found at: * https://github.com/iamstuartwilson/strava * */ // Bootstrap Processwire include __DIR__ . '/../index.php'; // Include the PHP Library for working with the Strava v3 API include __DIR__ . '/StravaApi.php'; // Strava credentials (you can get these from the Strava app page you've created) $clientId = "Your clientId"; $clientSecret = "Your clientSecret"; $accessToken = "Your accessToken"; // Connect to Strava $api = new StravaApi( $clientId, $clientSecret ); // Set the parent where activities will be stored as child pages $activity_parent = wire('pages')->get("/activities/"); // Get new activities $results = $api->get( 'athlete/activities', $accessToken, array( 'after' => $activity_parent->strava_last_checked ) ); // Uncomment if you want to inspect the $results response onscreen // echo "<pre>"; // print_r($results); // echo "</pre>"; // Import new Strava activities to PW Pages if (empty($results)) { // Log that no activities have been imported $text = "No new activities have been imported"; $options = array('showUser' => false, 'showPage' => false); wire('log')->save('importer_strava', $text, $options); } else { $numImportedPages = 0; // Start counter for number of imported pages foreach ($results as $result) { $p = new Page(); // Create new page object $p->template = 'activity'; // Set template $p->parent = $activity_parent; // Set the parent // Assign $result data to the corresponding Page fields $p->name = $result->id; $p->title = $result->name; $p->act_distance = $result->distance; $p->act_moving_time = $result->moving_time; $p->act_elapsed_time = $result->elapsed_time; $p->act_total_elevation_gain = $result->total_elevation_gain; $p->act_type = $result->type; $p->act_start_date = substr($result->start_date_local, 0, 10); $p->act_average_speed = $result->average_speed; $p->act_start_lat = $result->start_latlng[0]; $p->act_start_long = $result->start_latlng[1]; $p->act_end_lat = $result->end_latlng[0]; $p->act_end_long = $result->end_latlng[1]; $map = $result->map; $p->act_map_polyline = $map->summary_polyline; $p->save(); // Save the Page object $numImportedPages++; // Increment counter } // Log the number of activities that have been imported $text = ($numImportedPages == 1) ? "$numImportedPages new activity imported" : "$numImportedPages new activities imported"; $options = array('showUser' => false, 'showPage' => false); wire('log')->save('importer_strava', $text, $options); // After the import, update Field 'strava_last_checked' to current Unix timestamp // This could also be placed outside of the 'else' to update on each script run $timestamp = $activity_parent; $timestamp->of(false); // Turn off output formatting before saving things $timestamp->strava_last_checked = time(); $timestamp->save('strava_last_checked'); }
    1 point
  21. Hi there, Nick, and welcome to the forum! PW can handle this, but this isn't something any single module alone will do for you. It'll require custom code work, the amount of which depends a lot on how many users you'll have, whether you're prepared to create user accounts and connect them to editable pages manually or if you need to automate registration, how customised you want edit views for these clients to be etc. Below I'll try to describe three possible approaches you might use to make this work: 1. Keep client's user profiles (i.e. user accounts, which in ProcessWire are also pages) and publicly viewable product/info pages separated. Each user would have an account to your site but also separate, publicly viewable page he/she can edit. For this approach, I'd start with Page Edit Per User module, which allows you to define pages that specific user (one with no access to edit any pages by default) can edit: /clients/ # public part of your page /client-x/ /client-y/ /client-z/ # page for client z: publicly viewable info, products etc.; # after logging in, client z can edit this page /processwire/ # ProcessWire admin area /access/ /users/ /client-x/ /client-y/ /client-z/ # user account for client z: not publicly viewable; after # logging in, this client can edit page /clients/client-x/ 2. Add product information etc. custom fields directly to user's profile pages and then render those publicly. The problem with this approach is that all your users, including superusers, will have these custom fields, which might not make sense in your case (if you need other type of users later, it's going to be very confusing). Also, you'll still need public URLs for the profiles -- not much of a problem though, as you can always create a template that fetches user (like Pete descried in the thread linked to above), either based on a GET param or URL segment. If you go with this, be very strict with validation, i.e. before rendering user page make sure it's one that should be rendered, i.e. one of your clients and not, say, superuser account. 3. If you're confident in your skills with code, you could also create a Process module (a new view/tool for Admin area) that your clients use to handle their products. This would, essentially, be a custom-built CRUD tool for managing user-specific pages. This thread provides some useful pointers for this. Using this approach it would actually make sense to include basic info as custom fields on user profiles as explained above and creating separate pages only for products these clients sell (assuming that there's more than one product per each client). Hope I didn't confuse you too much with this -- please don't hesitate to post any questions this raises and/or you still have. Would be happy to clarify. I'd strongly suggest that you start building this thing and then ask once you face any specific issues.. the more you can limit the scope of your question, more likely you are to get a swift and precise answer
    1 point
  22. Hi, jukooz and welcome. 1) For simple websites you could use usual includes to reuse your building blocks. See the home.php and basic-page.php for the example in site/templates/ folder. Also see this really cool thread about different approaches to templating. 2) You could create a page using a special template with all the necessary fields to store your global variables. Then you could access it everywhere in your template them as easy as: $globalVars = $pages->get("/path/to/your/page/"); // you can also use page id instead of url $globalVars->fieldname; You could include it in your header.inc so that you don't have to call it every time. 3) You could use a "show (hide) in secondary menu" checkbox for your pages and then check against its value in your code to show only items you need. Have you seen this already?
    1 point
×
×
  • Create New...