Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 04/24/2013 in all areas

  1. In a rare display of personal work I’ve made a photographic site to show some of my pics. I hope you like it. http://stlmv.in/mw
    7 points
  2. I'm using Font Awesome, and wanted to be able to add icon markup to parent pages only. Soma mentioned using "xtemplates", but in my case parent and child pages all use the same template. So after I flew to Switzerland to hand Soma a beer, he suggested I use a hook. This may be useful to someone else, so here's what I did: 1. add a text field called "icon" to your template. 2. add the code below before you call $treeMenu->render(); function addIcon(HookEvent $event){ $page = $event->arguments[1]; if ($page->icon){ $event->return = "<a href='{$page->url}'><i class='icon icon-{$page->icon}'></i> {$page->title}</a>"; } } $treeMenu->addHookAfter('getTagsString', null, "addIcon");
    3 points
  3. Hi Rick, head.inc and foot.inc don't represent literally the html <head> or <footer>, they are just there to hold code that is common to most pages. That's why you find navigation and summaries there. They could be called top.inc and bottom.inc or start.inc and end.inc, but those names are generally recognized among developers, so it makes sense to use them on the default install. You are the one choosing the level of editability (my spellchecker doesn't like this word) of the sites you design. Some times it makes sense that everything is editable, and processwire for sure allows you to do this, other times you want a bigger control over some aspects of the website, and make it available for the editors to change only what's necessary. In the latter case it makes sense to have some content hard coded. You should do it, we all are. The default install serves only as an example. Ryan created the most simple site that still has some complex snippets of code, here and there, that you can take as example, with few templates and fields, but that represent a lot of you can do with pw. Do as you wish—use some code and some of the fields and templates, or just wipe it all and start from a blank state. But make sure you learn from it because it's full of nice details
    2 points
  4. Sorry it's been a while since I last updated you guys on this theme. I was moving house when I started this theme and then I didn't have the internet for a few weeks and then I was ill. lol. But I'm all better now and I've continued developing this theme. Before you see the new screenshots of it's progress I just want to share what I found while developing this theme. I found the markup for the admin theme a bit messy. Styling all the fieldsets for example was quite a challenge because some fieldsets are within fieldsets and so you end up with this doubling up effect. As I started to discover more of the admin theme I realised there are a lot of user experience issues and some fieldsets can be quite heavy. Once I've finished this theme I would very much like to offer my help in suggestions for improving the overal experience of the admin. So I took all my learning into consideration and tried to think of the best way to develop a theme that I could build and suited ProcessWire's current way of presenting information; which so far has led me to this approach. I haven't included the header or footers in these screenshots because I'm still playing around with it. Example of editing Guest role: Example of editing Admin user: Example of editing Field module: As you can see it's changed quite a bit, but I'm feeling a lot more confident about where I want to go with this theme. I'll keep you guys updated in the following weeks as to when I'll release an alpha version of it so you guys can help me find any quirky bugs with it. Thanks for listening.
    2 points
  5. Thanks for your help, guys! I changed the section tag to an article, moved the tags inside the loop, and added your code, diogo, and it's working beautifully. Thank you again!
    2 points
  6. I haven't tried this module with languages support, but thanks for letting me know that they are not compatible. You should be able to retrieve the $languages API variable via the wire() function, i.e. wire('languages') or wire()->languages are both valid syntax. $languages is a PageArray and can be iterated. Multi-language field types implement FieldtypeLanguageInterface. If you wanted to find all multi-language fields in the system, you could do this: foreach(wire('fields') as $field) { if($field->type instanceof FieldtypeLanguageInterface) { // this is a multi-language field } } Something else to mention about multi-language fields (all of which are text-based, currently) is that their value is actually an object of type LanguagePageFieldValue, rather than a string of text. Its __toString() value is reflective of the user's current language. When outputFormatting is on (as it is on the front-end), it is converted to a string automatically. But when outputFormatting is off (as it is in the admin) the value is a LanguagesPageFieldValue object. There is also another type of multi-language field known as a Multi-language alternate field.These are quite a bit simpler in that they are just a regular field with any fieldtype. But they are recognized as multi-language by name convention. If you have a field named "myfield" and another named "myfield_es", and you have a language installed named "es", then "myfield_es" is assumed to be the Spanish version of "myfield", while "myfield" is assumed to be the default language version. On the front-end (outputFormatting on) ProcessWire knows to substitute one for the other when the user's language matches the field name. If there is a lot of code involved in configuration of an autoload module, then I prefer to put it in a separate file so that it's not taking up any memory for the non-admin requests that don't need it.
    2 points
  7. I think I understand the request, but feel this probably belongs as a module since it such a specific need. My opinion has always been that the core should only have features that would be regularly used in at least 30% of installations. Otherwise we run the risk of having too much, over-configuration, etc. There are actually some modules we now have in the core that aren't used in at least 30% of installations (anyone ever used FieldtypeCache or some of the lesser known Textformatter modules we include?), so these will likely be moved out of the core in an upcoming version of PW. When it comes to meeting specific needs, I prefer to update the core to add new hooks where necessary (for modules) rather than adding new functionality or configuration. I think your case is one that does sound like a useful capability, but I'd prefer to assist you in implementing it as a module rather than adding it to the core. I'm sure some others will find it useful too, so would like to see it in the modules directory too.
    2 points
  8. Welcome to the forum jwaldeck. You're right that the multilanguage methods documentation are a bit dispersed on the forum (ok, a lot). It's a great idea to write this document. Right now i can't help you with this, but I can describe very simply, what i did in a site that wasn't built for multilanguage, and I had to add it very quickly http://museudoresgate.org/. Because the site is really small and I was in a rush, I just added a new page in english for each one of those that wanted to be translated. They were right there in the tree, next to the others, because I didn't wanted to change the structure that I had. I also didn't want "pt" and "en" in the url. I created a checkbox "english" with the label "english page?" and made it global. I also created a page field for the portuguese pages with the label "corresponding page in english" only with pages with that checkbox checked (all english pages), and also made it "single page" and global. The menus were build manually, so, I just had to check if($page->english) and render the correct items for each language. To link to the corresponding page in the other language I used the page field like this: <a href='<?php echo $pages->get("corresponding_page=$page")->url ?>'>PT</a> and <a href='<?php echo $page->corresponding_page->url ?>'>EN</a> That's it! I only had to make sure that each english page is using the same template as the same portuguese page and fill it with the translations. Only thing that took more time were the hardcoded things that I had in javascript (don't tell anyone...)
    2 points
  9. Hi all, this is first complete version of czech localization pack for ProcessWire 2.3. Almost 100% of text strings are translated. Please download and test this pack. Send me any comments to improve it. I decided that version 1.0 will be published after longer testing period. Current version: 0.9.1 pw_czech_091.zip
    1 point
  10. I found (after 2-3 Projects using PW) that it's a good technique to use templates in a way I think hasn't been thought of yet really by some. (Although the CMS we use at work for year, works this way.) I'm sure I'm maybe wrong and someone else is already doing something similar. But I wanted to share this for everybody, just to show alternative way of using the brillant system that PW is. Delegate Template approach I tend to do a setup like this: - I create a main.php with the main html markup, no includes. So the whole html structure is there. - I then create page templates in PW without a file associated. I just name them let's say: basic-page, blog-entry, news-entry... but there's no basic-page.php actually. - Then after creating the template I make it use the "main" as alternative under "Advanced" settings tab. So it's using the main.php as the template file. - This allows to use all templates having the same php master template "main.php" - Then I create a folder and call it something like "/site/templates/view/", in which I create the inc files for the different template types. So there would be a basic-page.inc, blog-entry.inc ... - Then in the main.php template file I use following code to delegate what .inc should be included depending on the name of the template the page requested has. Using the TemplateFile functions you can use the render method, and assign variables to give to the inc explicitly, or you could also use just regular php include() technic. <?php /* * template views depending on template name * using TemplateFile method of PW */ // delegate render view template file // all page templates use "main.php" as alternative template file if( $page->template ) { $t = new TemplateFile($config->paths->templates . "view/{$page->template}.inc"); //$t->set("arr1", $somevar); echo $t->render(); } <?php /* * template views depending on template name * using regular php include */ if( $page->template ) { include($config->paths->templates . "view/{$page->template}.inc"); } I chosen this approach mainly because I hate splitting up the "main" template with head.inc and foot.inc etc. although I was also using this quite a lot, I like the delegate approach better. Having only one main.php which contains the complete html structure makes it easier for me to see/control whats going on. Hope this will be useful to someone. Cheers
    1 point
  11. Hello professional PW world! Not being a developer/designer myself (its rather my hobby), I've liked PW for its simplicity and flexibility and even developed simple site with it. However more complex sites require time to grow professionalism in PHP/JS/design/etc - something that I can't get quickly and without impact on my main work. As a result, I'd like to post job here. In brief - I'm looking for professional PW + PHP developer for full-cycle PW-powered site development. Site will be analogy of coachup.com. Differences come from content that will be provided during development (another business area, specifically, education + content language is Russian (but I'll need to leave possibility to easily switch to other languages)). All the rest (front-end design concept, site structure, frond-end and back-end functionality, etc) is the same. Please check this site to get full picture and understand scope of work. Take into account that functionality includes work with external APIs: authorization from social sites, Google maps, payment gateway, support chat. Hope this helps to estimate budget and time. Please contact me with questions and proposals at andrey.valiev@hotmail.com. Or leave comments here. Thank you! Best regards, Andrey P.S. As I plan to develop few other PW-powered sites, more job may come.
    1 point
  12. Lea Verou explains Regular Expressions. This is actually very easy to follow! Her RegExp playground is pretty cool too http://leaverou.github.io/regexplained/. And since we are at it, check out this Regexp editor by Cody Lindley http://jsfiddle.net/codylindley/u4E6P/
    1 point
  13. A huge thanks to Diogo who has been helping me debug this. He eventually found out the cause of the error was the $page->invoice_line->removeAll(); line. It seems to require a save() after this line and then a further save at the end. if ($error == 0) { $page->of(false); $page->invoice_line->removeAll(); $page->save(); $page->of(false); $page->title = $sanitizer->name($input->post->number); ... $page->save(); Could Ryan confirm this is the correct way? Diogo, mucho obrigado
    1 point
  14. Actually $file->basename is there too. It's the same thing as $file->name. The $file->name is mainly there for consistency with other PW objects, in that we want everything in ProcessWire to reliably have a 'name' property. But I usually use $file->basename myself.
    1 point
  15. I've been working on something similar recently too. Let us know how it goes and if you run into any issues.
    1 point
  16. If you want to integrate Google+ Comments in your ProcessWire website, just follow the instructions from an article on Browsing the Net. In summary, insert the following HTML code into your template: <script src="https://apis.google.com/js/plusone.js"></script> <g:comments href="<?=$page->httpUrl?>" width="642" first_party_property="BLOGGER" view_type="FILTERED_POSTMOD"></g:comments> Change the width accordingly and in case you have a Google+ profile, link your page with Google+ profile to enable moderation features.
    1 point
  17. Your closing </section> is also outside of the loop and should be moved inside.
    1 point
  18. @jmartsch, I think you encounter the same as the previous poster? is openssl installed? I just pulled in an update from petsagouris with multitude of changes, one of which checks for the openssl module being installed. udpate 1.0.7 - multitude of fixed and code cleanup (@petsagouris) - added check for openssl module required for https download stream (@petsagouris) - added back to Modules Manager button on download/update screen
    1 point
  19. Hi, @MarcC Ideally having a check for data and populate fields would be a great idea. In my case my setup looks like this. As you can see there'll be scans from the YashicatMat that probably won't show anything because it records no data and I haven't written anything down for the shot .
    1 point
  20. here is the little module that adds auto population for single textfields with exif or iptc data: http://processwire.com/talk/topic/3398-working-with-processwire-getting-exif-data-from-images/#entry33552 Many thanks for your kind help Soma!
    1 point
  21. I have written a little module that extends Somas awesome Images Manager. Also it's written with Somas kind help, (thanks!) It adds auto filling of EXIF or IPTC fields where available on upload of new images through Images Manager. How to use it: You, of course have Images Manager installed and ready to run. Now you have to create some fields that should take your exif data: fieldname prefix is exif_ followed by the original exif-fieldname but lowercase! ( exif_author, exif_copyright, etc.) ALSO you have to create one TextArea field called (by default) image_exif, - this one and ... (not needed, only optional to get the full raw EXIF-data stored) all your exif_fields you have to add to the image-template that is used by Images Manager for creating the new Image Pages. then download and install the ImagesManagerMetadata module. here are a little screencast I've done with it: https://youtu.be/wjhJdT7Tf5Y this is alpha, version 0.0.2 ImagesManagerMetadata.zip
    1 point
  22. Nice tool for testing websites and apps on several android formats https://www.manymo.com/
    1 point
  23. I think what's wrong is that you get the field object and not a value. $pt_field = $item->$field; and $item->$field = $pt_field; If you would output the $item->$field; you'll still see the old value I guess. If you would stringify by either add "$item->$field" or (string) $item->$field it would work. Also you're cycling each field on page I think isn't good idea. You should restrict to those fields that you want to change. I would do this instead, with an array you can define what fields, and also use the $field->getLanguageValue(langID) to get values. // define fields you want to change $fieldsArr = array('title','body'); $langAlt = $languages->get("de"); $langDefault = $languages->get("default"); $pa = $pages->find('/about/'); foreach($pa as $p){ $p->of(false); foreach($fieldsArr as $field){ $title = $p->$field->getLanguageValue($langAlt); // get the alternative lang value $p->$field->setLanguageValue($langDefault, $title); // set the new value } $p->save(); }
    1 point
  24. If it is shared hosting, then it might be your neighbor who is getting all the visitors, but blocking the road for your house too...
    1 point
  25. ( ohne Worte - without words )
    1 point
  26. That wasn't a good idea, you didn't say anything really wrong there, but now it looks like you did... And the referee was too quick with the yellow card
    1 point
  27. Good question. This is one of those "one man's meat is another man's poison" sort of situation. There are so many different approaches to doing your template files...No one approach is superior (in most cases ) to another. It is an issue of preference. You can even decide you want all your HTML code with PHP inside in one file. This can result in very long, hard-to-grasp code though. You can decide not to name your includes as .inc but .tpl..PHP will happily include them when asked to do so....Or, you can have as many .inc as you wish to make your head spin trying to guess what is including what . I hope it doesn't confuse you more but have a look at this thread. It has lots of wonderful ideas about approaching your template files. Having .inc files also helps with dynamism. For instance, your website can have the same header throughout but different footers depending on the page being viewed. There can be a sidebar.inc as well, which will only appear in certain pages and show a sub-menu, a featured article, etc.... I am working on a short tutorial part of which I hope to post here soon...(and on my website whenever that materialises ) about visualizing your site structure before you build it. Planning is important in these things. Again, people have different approaches. I like to think diagrammatically, at the whole system level. Such an approach helps me visualise the template approach to adopt for a particular job. For instance, what areas of the website are common/shared? What is unique to some pages? How best can I code/design/plan my templates and template files to achieve what I want making best use of logic, KISS and DRY principles and balancing this against common sense and ease of understanding the code? If I come back to the code in a month's time, or if somebody took over my task, would I/they be able to make sense of it all? Sorry for digressing somewhat
    1 point
  28. When working on ImageEditor (formerly named ImageManipulation) I come across some points that I want to [ discuss | get advice | point out ] ----- 1) The ImageEditor now can be used like this: $myImage = $page->images->first; $imedit = new ImageEditor($myImage); if($imedit->imRotate(90)->imResize(300,0,false)->imSharpen('soft')->imSave()) { echo '<img src="'.$myImage->url.'" />'; } It needs a PageImage as source. This can be an original Image, but than it needs a targetFilename, because it doesn't allow to overwrite the original Image! When it gets an ImageVariation it can save to that filename (overwrite). You also may save to another image format, e.g. your source is JPEG and you apply some alpha masking vodoo to it, you want to save it as PNG. This can be done by define the optional option outputFormat. ----- 2) I think there is a need for a additional Image Method: $image->nameAppendix() or something like that because there is allready a naming convention for images ( originalimagename.300x0.jpg or originalimagename.0x300.jpg ) that could be extended to something like originalimagename . 300x0 (userdefinedAppendixWrappedBySpecialChars) .jpg The $image->nameAppendix('userDefinedAppendix') should set or exchange this filename part. This would be of great help to keep imagenames consistent across the site. I have read a thread where Ryan has said that when trying do delete all Variations of a site that cannot be done by iterating through $images and use ->removeVariations() for large sites. On the other hand when users or module authors can name the images without be restricted that may become a mess with imagenames. At least there should be defined a image naming convention with respect to UserNameAppendices, - than I can implement it into the ImageEditor. ----- 3) I need some advice on how to handle Errors & Warnings, e.g. when not all needed options are passed, or they aren't valid. Should we silently use defaultValues where available or should we use that and write to ErrorLogFile. Don't know how fast a Logfile can grow, or even more terrible, - when should I throw an Exception? When gets an admin email invoked? I can upload the code or provide otherwise more informations on that. Please ask / tell what is needed. ----- 4) Here are some examples / possibilities of usage: $myImage = $page->images->first; $imedit = new ImageEditor($myImage); output of $imedit->image : array(10) { ["type"] string(3) "jpg" ["imageType"] int(2) ["mimetype"] string(10) "image/jpeg" ["width"] int(1800) ["height"] int(1196) ["landscape"] bool(true) ["ratio"] float(1.505016722408) ["bits"] int(8) ["channels"] int(3) ["colspace"] string(9) "DeviceRGB" } $myImage = $page->images->first; $imedit = new ImageEditor($myImage, $options); //second param is optional $options array like with ImagesSizer /** * valid options, identical to that 5 from (new) ImageSizer, * width 3 additions: targetFilename and outputFormat * * - targetFilename is needed because we don't want to overwrite the original Imagefile * there are two exceptions: * 1) if you have allready created a variation and have passed that to the ImageEditor * than a targetFilename is not needed. * (we check reference '$image->original' to know about that) * 2) using the static function fileAutoRotation, because this is mainly implemented * for correcting an original imagefile on upload! So a file gets uploaded only one * time and only then we may apply rotation to the original image. * * - outputFormat is optional and only should give ability to * import for example a JPEG, do something with fancy masking and * save it to PNG-Format with alpha transparency. * * - bgcolor may be used when wrapping borders around an image or create Thumbnails like Slides * (squares with landscapes or portraits in it) * */ protected $optionNames = array( 'autoRotation', 'upscaling', 'cropping', 'quality', 'sharpening', 'bgcolor', 'targetFilename', 'outputFormat' ); // you may also at any point get out the memoryimage, apply your own stuff like a SepiaFilter and put it back: $myImage = $page->images->first; $imedit = new ImageEditor($myImage); $im = $imedit->imRotate(90)->imResize(300,0,false)->imSharpen('soft')->imGetIm(); imagefilter($im,IMG_FILTER_GRAYSCALE); imagefilter($im,IMG_FILTER_COLORIZE,100,50,0); $imedit->imSetIm($im)->imSave(); // the OneLiner // this one should get invoked when an image is uploaded public static function fileAutoRotation( $filename, $quality=95 ) // and this one is a present for apeisa, (but pssst, don't tell him) public static function fileThumbnailModule( $filename, $src_x, $src_y, $dst_w, $dst_h, $src_w, $src_h, $quality=95, $sharpening='medium' )
    1 point
  29. This should be possible. You'd use a Pages::saveReady hook. You'll want to have your hook do something along these lines: if($page->template == 'album' && $page->isChanged('images')) { $newItems = $page->images->getItemsAdded(); if(count($newItems)) { // images were added, create your new unpublished blog post // the $newItems WireArray contains the images that were added } }
    1 point
  30. If you want to access another MySQL connection, you have any of the native PHP options (mysqli, PDO) available at your disposal. You could also use ProcessWire's Database class (derived from mysqli) to start another connection. Lastly, you could include some other library like to use ActiveRecord from Code Igniter, for example. Personally, I would just keep it simple and use Database, mysqli or PDO. But I would not use mysql_connect, because the old mysql driver in PHP is deprecated... you can use it, but your code might break in some future version of PHP. If you want to use PW's Database class, here's an example of how you'd do it: $mydb = new Database('localhost', 'user', 'pass', 'db_name'); $result = $mydb->query("SELECT * FROM some_table"); while($row = $result->fetch_assoc()) { print_r($row); } See PHP's mysqli functions, as the Database class essentially is identical to mysqli with some extra PW-specific stuff thrown in that won't matter if you are interacting with a non-PW database. To use native mysqli, you'd just replace "new Database(...)" with "new mysqli(...)".
    1 point
  31. I had a look at soundcloud sharing options, and they don't look very smart... Still, I think your best option would be using the wordpress option that looks like this: [soundcloud url=http://api.soundclou...racks/59046167" iframe="true" /] You have two options. One that represents more work to the editor but less processing work, one simpler to the editor but more complex in PHP. For both options, create a text field "song", and add it to the template. For the first option, teach the editor to get the wordpress sharing option in soundcloud, extract the number of the song [soundcloud url=http://api.soundcloud.com/tracks/59046167" iframe="true" /] and put it on the "song" field. The code on the template would be this: $song = $page->song; echo "<iframe width='100% height='166' scrolling='no' frameborder='no' src='http://w.soundcloud.com/player/?url=http%3A%2F%2Fapi.soundcloud.com%2Ftracks%2F{$song}}&show_artwork=true'></iframe>"; Second option, is a little bit easier to the editor because he doesn't have to look for the number on the wordpress code. Only copying it. [soundcloud url= iframe="true" /] Your code would have to be more complex, and a bit slower in terms of processing: $src = $page->song; preg_match( '/([0-9]+)/', $src, $matches); //extracting the numbers part of the url with a regular expression $song = $matches[1]; // and putting it on a variable echo "<iframe width='100%' height='166' scrolling='no' frameborder='no' src='http://w.soundcloud.com/player/?url=http%3A%2F%2Fapi.soundcloud.com%2Ftracks%2F{$song}&show_artwork=true'></iframe>"; edit: corrected some typos by WinnieB's suggestion
    1 point
  32. Here's my first attempt: https://github.com/p...ProcessWireTwig Sorry about the manual steps to get it going. I haven't had a chance to test things from scratch so let me know if I have left anything out of the README or if I have missed a file/setting. The example templates should essentially copy the basic-page.php template from the example site. It isn't pretty (especially the outer wrapper layout.html) as I just did a straight copy (rather than designing a site with Twig in mind) and haven't done any formatting tidy-up but should hopefully get someone started. Let me know what you think! Edit: Should I add code to the ___install() and ___uninstall() functions to create the views and cache folders (and delete the cache folder on uninstall)? Can the uninstall routine give a checkbox to choose to delete the twig views folder?
    1 point
×
×
  • Create New...