Leaderboard
Popular Content
Showing content with the highest reputation on 07/20/2013 in all areas
-
While you may be able to use some of these syntactic tricks when it comes to setting a value, I think it's better to treat a Page as a Page and a PageArray as a PageArray, just as a matter of keeping your code readable. If I have code that needs to deal with either a Page or a PageArray, but it doesn't know ahead of time which it will be, I usually treat it like this: if($value instanceof Page) { // treat it as a Page } else if($value instanceof PageArray) { // treat it as a PageArray } Or I normalize it to one or the other. For instance: if($value instanceof Page) { $a = new PageArray(); $a->add($value); $value = $a; } // now we can assume $value is always a PageArray3 points
-
3 points
-
Hi guys, It's been a while that I've posted here on the forum, the reason was - I got a new job few months ago so I've been rather busy and haven't got time to post some new things. I've made a Yahoo! Weather module that connects to Yahoo weather API and pulls current forecast and forecast for next 4 days. The module is completely ready for translation, I've also made days and weather conditions translatable because Yahoo API doesn't offer localization (English only). The widget has normal mode and compact mode and you can easily customize it's appearance through included CSS. Edit 12.04.2015. This module is not longer supported, check out the new version at this link. I'll fix some errors that are currently in this module for those of you who like the old version better then the newer one. Screenshot Download https://github.com/nvidoni/MarkupWeather How to install Copy module directory to /site/modules/ directory. Click check for new modules in ProcessWire Admin Modules screen. Click *install* for the module labeled: "MarkupWeather". How to use Copy this line to template of your choice where you want the weather widget to be displayed: <?php echo $modules->get('MarkupWeather')->render(); ?> This module has the following options: Yahoo! Weather Woeid Woeid is a number located right beside the city name, e.g. http://weather.yahoo.com/croatia/grad-zagreb/zagreb-851128/ Set Locale sets PHP locale, needed for date display localization Date Format date formatted with PHP strftime function Show 5 day forecast below current weather forecast? turn this off if you want to display compact weather widget, shows only current weather Display temperature in Fahrenheit instead of Celsius? show weather conditions in Celsius or Fahrenheit scale Hope you'll like it.2 points
-
There may be a way to do it from the SQL side, and that would probably be a good use case for using an SQL query rather than a selector. I don't currently have plans to make selectors support that level of query, as it's a pretty rare need (this being the first time it's come up). When a query needs to perform a currency conversion (and this is something I've had to do), I perform the currency conversion first, and then use the converted value in the selector query. That actually reminds me that I have a currency conversion module that I need to finish up and post soon.2 points
-
There's always ifttt.com too. Pair his short posts RSS feed to a FB status update.2 points
-
Hey Ryan, that is exactly what it is doing for me right now too. I can only assume that right now I need more sleep, but I'll keep an eye on it.1 point
-
I do - if you pick some from lower down the list the updated date is yesterday or the 18th, rather than the actual date the module was last updated. Something to do with ryan's recent tweaks to the modules page maybe? This may be showing in ModulesManager too I guess, but I just looked at the modules page on this website.1 point
-
echo html_entity_decode(__('you.text w <blink>htmls</blink>'));1 point
-
https://github.com/ryancramerdesign/ProcessWire/blob/master/wire/core/LanguageFunctions.php#L39 I think you can only split your text so that it doesn't contain HTML-tags. Also it isn't possible to write a wrapper function that does the splitting + translation + concatenation for you, because the translation-texts must be available in static form in code,1 point
-
Just add something like this to the top of your events index page. You could compartmentalize this into a LazyCron call, but for such a simple thing it's really not necessary. $events = $pages->find('parent=/events/, date<"-3 months"'); foreach($events as $event) { $event->of(false); $event->addStatus(Page::statusUnpublished); $event->save(); } Btw, when testing something out like this, always comment out the $event->save(); the first time and take a look at what pages get affected by echoing them rather than saving them, the first time around. i.e. // $event->save(); echo "<p>Unpublishing: $event->url</p>"; Once confirmed that it is behaving the way you want, then remove the echo and uncomment your save();1 point
-
I think that you are on the right track using Pages rather than Repeaters for your sections. Actually, it looks to me like all of this stuff is intended to be output as pages on the front-end anyway, so you may want to avoid using Repeaters entirely. Repeaters are great for specific use cases, but you are far better off using Pages when it comes to anything site-structure related. If I've misunderstood the need to use repeaters here, then one solution you could look at would be to simply include your section_header field in the year_wrap repeater, and specify in your field description that the user should only specify a section header when they want to change it, and to leave it blank otherwise.1 point
-
There's a 'page-publish' permission you can add and use that. It's not there by default but it's recognized by PW1 point
-
I took a closer look at this and realized we'd need to set that config.user variable in the admin theme, and that it'd be better not to have an admin theme dependency for this module. So what I did instead is updated your module to pass along the active tab index in it's JS settings (config.LanguageFieldTabs.activeTab). It determines the active tab based on: if a GET variable is present called "language", containing the ID of a language, it uses that. Otherwise it uses the current user's language. This way you can have it focus on the right language tabs when a user clicks "edit" from the Spanish version of a page, for example. Here is what my edit link looks like on the front end: echo "<a href='{$config->urls->admin}page/edit/?id=$page->id&language=$user->language'>Edit this page</a>"; If there is no "language" GET variable specified, then it just defaults to the current user's language, whatever that may be. The end result is that the tabs always focus on the right language. In testing here so far, it seems to work quite nicely. I just sent over a pull request for this update.1 point
-
That's not by design, and that's not how it works for me. Just tried it on a page with two image fields "screenshots" and "logos" and it shows images from both. The RTE image/file selection tools don't know anything about fields named "image" or "files", they just look for fields that extend FieldtypeFile.1 point
-
that reminds me of a game on the good old amiga 500: F/A-18 Interceptor...i started from a aircraft carrier and i flew with maximum speed through the golden gate bridge...1 point
-
Okay, I've solved this for now, tho it does add an extra find call. 1: Hanna only does text replacement - all you get back from a tag is text. So, my hannah code executes the query and returns the ids in a piped list $foundPages = $pages->find($pagesQuery); $idList = ""; foreach($foundPages as $img) { $idList .= "$img|"; } echo $idList; 2: I declared my field as a Concat field, with the formatting field as: [[pages_query pagesQuery=template=template-1]] 3: My code now receives the id list, in pipes, when referencing the field, which makes a 2nd call to find all the ids that were returned. $myIds = $page->query_pages; $myPages = $pages->find("id=$myIds"); foreach($myPages as $targetPage) I don't like having to make a second call to the db, as that's unecessary overhead. I may try to dive into hanna code code (heh) and see what it would take to return the original results, rather than doing text substitution. Ryan, any insight would be appreciated here Thanks again, Brent, for directing me to Hanna. It got me to 99% of where I want to be. EDIT: sleep always clears the head. seralize/unserialize to prevent a 2nd db trip I marked your answer as solved, thank you. I'll revisit the new Page form layout question at another time. -- adam1 point
-
I just downloaded 0.0.7 from the modules page. On install, I get: Module Install - TextformatterHannaCode Created Page: /processwire/setup/hanna-code/ Module Auto Install: ProcessHannaCode BLOB/TEXT column 'code' can't have a default value If I got to setup/Hanna, I get: Table 'pwire.hanna_code' doesn't exist I also get the same error message when trying to uninstall. EDIT: line 436 of TextformatterHannaCode, I removed "default '' " and it installed fine. I don't think will cause any unexpected issues... i'm using mysql, if that matters (567 I think)1 point
-
Hi Alevine, One way to accomplish this would be to use Ryan's Hanna code module. Set up a Hanna code, let's say "output_pages" to accept a selector parameter and output what you need. Create a text field that contains the Hanna code and the parameter like [[output_pages match=template=basic_page]]. Hope that helps, -Brent1 point
-
I posted my first Hanna Code here http://processwire.com/talk/topic/1182-module-image-tags/?p=400151 point
-
One other immediate solution is to use Ryan's Hanna Code. I adapted the module to Hanna code, and it seems to be working pretty well, although the tags are a bit different: {fieldname:2} and [[images f="fieldname" n=2]] It looks a bit more complicated at first, but it's not really. Here is a resumed explanation: defaults: [[images p="0" f="0" n="0"]] where p is the page number, f is the field name and n is the image position on that field. The above is equivalent to simply: [[images]] And it will get all the images from the first field of the "image" type on the same page of this Hanna Code field. Because: if $p="0"; // $p will hold the $page object if $f="0"; // $f will hold the first images field found on $p if $n="0"; // $n will echo all the images from $f From here you can have any combination: [[images n="4"]] // echoes the image on the forth position of the first image field of this page [[images p="1" f="myimages"]] // echoes all the images of the field "myimages" in the homepage That's it. Here is the string to import this Hanna Code: !HannaCode:images:eyJuYW1lIjoiaW1hZ2VzIiwidHlwZSI6IjIiLCJjb2RlIjoiXC8qaGNfYXR0clxucD1cIjBcIlxuZj1cIjBcIlxubj1cIjBcIlxuaGNfYXR0cipcL1xuJG15UGFnZSA9ICRwID8gJHBhZ2VzLT5nZXQoJHApIDogJHBhZ2U7XHJcbiRmaWVsZE5hbWUgPSAkbXlQYWdlLT5maWVsZHMtPmdldCgndHlwZT1GaWVsZHR5cGVJbWFnZScpO1xyXG4kbXlGaWVsZCA9ICRmID8gJG15UGFnZS0+JGYgOiAkbXlQYWdlLT4kZmllbGROYW1lO1xyXG5cclxuJGluZGV4ID0gJG4tMTtcclxuXHJcbmlmKCRteUZpZWxkIGluc3RhbmNlb2YgUGFnZWltYWdlcyl7XHJcbiAgICBpZigkbil7XHJcbiAgICAgICAgJGltYWdlID0gJG15RmllbGQtPmVxKCRpbmRleCk7XHJcbiAgICAgICAgJGltYWdlID0gXCI8aW1nIGNsYXNzPSdJbWFnZVRhZ3MnIHNyYz0nJGltYWdlLT51cmwnIGFsdD0nJGltYWdlLT5kZXNjcmlwdGlvbic+XCI7XHJcbiAgICB9IGVsc2Uge1xyXG4gICAgICAgICRpbWFnZSA9IFwiXCI7XHJcbiAgICAgICAgZm9yZWFjaCgkbXlGaWVsZCBhcyAkaW1nKXtcclxuICAgICAgICAgICAgJGltYWdlIC49IFwiPGltZyBjbGFzcz0nSW1hZ2VUYWdzJyBzcmM9JyRpbWctPnVybCcgYWx0PSckaW1nLT5kZXNjcmlwdGlvbic+XCI7XHJcbiAgICAgICAgfVxyXG4gICAgfVxyXG4gICAgXHJcbn0gZWxzZSBpZigkbXlGaWVsZCBpbnN0YW5jZW9mIFBhZ2VpbWFnZSl7XHJcbiAgICAkaW1hZ2UgPSBcIjxpbWcgY2xhc3M9J0ltYWdlVGFncycgc3JjPSckZmllbGQtPnVybCcgYWx0PSckZmllbGQtPmRlc2NyaXB0aW9uJz5cIjtcclxufSBlbHNlIHtcclxuICAgICRpbWFnZSA9IFwiXCI7XHJcbn1cclxuXHJcbmVjaG8gJGltYWdlOyJ9/!HannaCode1 point
-
Hello Ryan and others! I've got a situation in which I'm hankering to use nested repeaters, and would love anybody's thoughts about alternatives that make sense. I'm creating a website that needs to display artist CVs with very strict formatting guidelines. The HTML I'll be outputting will look something like this: <div class="section_wrap"> <div class="section_header">One-Person and Collaborative Exhibitions</div> <div class="section_body"> <div class="year_wrap"> <div class="year">2012</div> <div class="year_entry_wrap"> <div class="year_entry">Item 1</div> <div class="year_entry">Item 2</div> </div><!--/year_entry_wrap--> </div><!--/year_wrap--> <div class="year_wrap"> <div class="year">2011</div> <div class="year_entry_wrap"> <div class="year_entry">Item 1</div> </div><!--/year_entry_wrap--> </div><!--/year_wrap--> </div><!--section_body--> </div><!--/section_wrap--> <div class="section_wrap"> <div class="section_header">Group shows</div> <!--and so on--> The nested repeaters I would use if I could would work out something like this: "section" (fieldtype:repeater) "section_header" (feldtype:text) "year_wrap" (fieldtype:repeater) "year" (fieldtype:text) "year_items" (fieldtype:text) That way, I could have a template called CV with the field "section" in it, and each CV could be entered as one page, with a page tree structure like this: Home CVs Artist 1 Artist 2 Etc... The workaround solution I'm thinking about now (though I'm sure there is something better) is to have each section be a different page: Home CVs Artist 1 Section 1 Section 2 Etc Artist 2 Section 1 Section 2 Etc Etc I'm still relatively new to PW and PHP, so if the answer is apologies if this seems like a silly question. I'm getting close to finishing my first major project with PW and have absolutely loved it, both for the framework itself and for the amazing community. Thanks in advance!1 point
-
You mean something like this? Those are 3 fields within a repeater given individual widths, in this case 30%, 35% and 35%...the rest PW does automatically. They could as well have been 60%, 40%, 100%. In this case, the former two would be lined up side by side and the latter drop down to its own row... If this is what you want: When editing the repeater field, under Details, where you add fields to a repeater, hover your mouse over the field name, click on the arrow that appears to the right of the field name, a modal will open up and set your width there..Fields given custom widths always have those widths displayed on the far right side of the field name when you view Templates->Basics Edited for clarity1 point
-
I agree. Maybe we could manage to make the docs on the website semi-collaborative by creating a "docs collaboration" forum, from where some things would be added to the website after discussion and approval. People seem to be much more active here than in the comments on the website.1 point
-
Nice find, thanks Dave. Recently I've not looked further than http://dimsemenov.com/plugins/royal-slider/ but this looks like it might compliments that well.1 point
-
If account_status is of single page select it won't have a add() method like PageArrays have. Multiple page select $new_page->$field->name->add(1023); // like $new_page->account_status->add(1023); // and also this (which seems to append db entry) guess makes sense? $new_page->account_status = 1023; Single page select $new_page->$field->name = 1023; // like $new_page->account_status = 1023; // but not $new_page->account_status->add(ID); // wrong So the page field can have different types based on the dereference settings multiple or single and behave slightly different. Single: it will only be a value of type page and page have no method add, multiple: will be a PageArray. PageArrays have the method add() to add pages, but also the field recognizes just ID's set to it, and it will save the entry and the others already saved or doublicates remain untouched. So to clear a multiple page field you have to call field->removeAll() first. You get this error because the value is most likely not an object (yet). If it dereferences as "single page or false if none selected (!)" .. so if the field is empty it will throw an error: Error: Call to a member function add() on a non-object If you would have already saved a value you would get this error instead, same code but different message because the field now has a page object set: Error: Exception: Method Page::add does not exist or is not callable in this context Hope this shares some light.1 point
-
Dear Teppo, In the first example, with the $field_value input coming from a form post, I iterate over an array of field names, getting $field_name from that array. In the second example, the user has filled out a form, and the code in the first example parses most of the ordinary fields. Then, after that has been done, prior to saving the new page, I need to set the values on a small group of 'admin' type fields, like account_status. Account status is of FieldtypePage, (a single select dropdown). I'm trying to set the field to one of the values ('Trial'), which of course has a page ID. So, since I already know the field name, and the value, I just have to figure out the code to set the value. I want to be able to do the same thing for multi-selects or multi-checkboxes as well. I thought I had to add those values, using the $field->add function, as I did with the 1st example which process user form post input, but then I ran into that error. I'm sure I'm missing something obvious to an OOP expert, but I haven't figured it out yet. This whole thing is a front-end app for members, where they will add, edit and delete pages, all through the API in custom php files. I've got most things working... I'm just stuck on this little point, at the moment. I'm deliberately not using the form API, because I'm using HTML templates with field tags, and then replacing them with values or input fields. Yours, Peter1 point
-
@Peter: $field = $fields->get("account_status") returns a field object. This would in turn return field ID when converted to string. This explains the error you're getting: while $new_page->account_status returns field called "account_status" attached to that particular page, $new_page->123 (or whatever the ID of that field is) won't work (fields are called with their names, not ID values) and thus it returns an error when you try to use method "add" of this non-existent object. Am I making any sense here? Anyway, reading you post again, I must admit that I don't really get how your application works. There's just not enough data here, I'm afraid. For an example your first example gets field value from $input->post->$field_name but field name itself ($new_page->$field->...) seems to already exist at that point. This is why I'm having a bit of a hard time understanding the relation between these two code examples.1 point
-
New czech localization pack is done. Current version: 0.9.4 (92 files) Changelog: Deleted files: wire--core--upload-php.jsonAdded files: wire/core/WireHttp.php wire/core/WireUpload.php wire/core/Pages.php wire/modules/LanguageSupport/LanguageSupportPageNames.module wire/modules/LanguageSupport/LanguageSupportFields.module Fixed bug with setlocale in wire--modules--languagesupport--languagesupport-module.json (missing UTF-8 suffix) Added some missing strings Updated some strings pw_czech_094.zip1 point
-
1 point