Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 05/18/2014 in all areas

  1. Some progress. Adding: $f->attr('dateInputFormat', "Y-m-d"); $f->attr('timeInputFormat', "g:i a"); populates the time as well, but it is always 12:00 am, ignoring what is set in the value. I'll keep experimenting and report back. EDIT: Ok, I got it - you need to set the value to the unix timestamp Final code: $f = $this->modules->get("InputfieldDatetime"); $f->name = 'changes_since'; $f->label = 'Changes since'; $f->datepicker = 3; $f->attr('data-dateformat', "yy-mm-dd"); $f->attr('data-timeformat', "hh:mm:ss"); $f->attr('dateInputFormat', "Y-m-d"); $f->attr('timeInputFormat', "H:i:s"); if($form->get('changes_since')->value){ $f->attr('value', $form->get('changes_since')->value); $f->attr('data-ts', $form->get('changes_since')->value); } $f->attr('class', 'FieldtypeDatetime'); $form->add($f);
    3 points
  2. Reviving this old topic.... For pages created in bulk using the API, many will have the same timestamp (e.g. batch create 1000 pages using the API); the only unique thing for such pages will be the ID. If I limit my selector to one template only, the ID then becomes a more reliable get selector to use with < or >. The assumption here is that since IDs are incremented, a greater ID denotes a later created time. In bulk page creation then, the timestamp is less reliable and will return the same result every time which is of no good use when creating next/prev links ...maybe I'm missing something?
    3 points
  3. Well, since Teppo doesn't announce it himself (Twitter doesn't count), here it goes http://www.flamingruby.com/blog/processwire-weekly-1/ What a great idea! Now I won't have the feeling that I'm missing important things on those weeks where work (or vacations) brings me away from the forums. Thanks Teppo!
    3 points
  4. Oh and field name would be a attr $f->attr("name", "myname"); Something like this works perfectly. $f = $modules->InputfieldDatetime; $f->label = "MyDate"; $f->attr("name+id", "mydate"); $f->dateInputFormat = "Y-m-d"; $f->timeInputFormat = "H:i:s"; $f->attr("value", time()); echo $f->render();
    2 points
  5. Just only need $f->dateInputFormat = "Y-m-d"; $f->timeInputFormat = "H:i:s"; the attr(key,value) is for html attributes and data-dateformat will get written by the inputfield automaticly.
    2 points
  6. Please use Matrix Fieldtype & Inputfield Or the ProFields. FieldtypeJson (module) Álpha I've been busy last 2 weeks with a new fieldtype. I needed a fieldtype that generates JSON strings from CSV (excel data). I needed a way to handle a variable amount of columns & needed a way to manage that data. Wanze & Kongondo already worked on a excel crud module with the excellent Excel-like data grid editor Handsontable and I loved that piece of software. Thank you guys. Handsontable is used in the Inputfield part. What the Inputfield does does: If there's no data in the field, the Inputfield shows you a textarea. You could copy 'n past in CSV text in that field. When you save the field, all data is processed. Processing means: Slice till an x amount of data rows. If minimum amount of columns is not reached, pad the columns till the amount you've specified in the settings If the data contains to much columns, slice the redundant amount of columns. Every data left, is trimmed and sanitized Every numbered string will be converted to integers Saved in 2 formats: 1) json and 2) cvs Server side there's a lot of processing needed to perform all this, that is the reason to set a low amount of data rows. On The Inputfield side, the JSON is generated by Handsontable. So this feels a bit dirty. (Server side it does do all the steps in the above list.) For now it's called FieldtypeJson, but i'm not to keen on this name. Output How to output in your template: $page->fieldname // (string) the table markup $page->fieldname->json // (string) JSON string $page->fieldname->csv // (string) CSV string $page->fieldname->rows // (int) number of rows, not really usefull, but needed internally $page->fieldname->columns // (int) number of columns, not really usefull, but needed internally When to use: If you need a small set tabular json data, and you don't know how many columns it has. If you want to have render tables quicky in your site. When not to use: Store very large sets of query -able data. If you have to rely rely on the data. ( all json is stored in a subfield, and the same for csv ) API Side (JSON): // Json string $json = '[["First Name","Last Name","Company Name","Address","City","State","Post","Phone","Email"],["Rebbecca","Didio","Brandt, Jonathan F Esq","171 E 24th St","Leith","TA","7315","03-8174-9123","rebbecca.didio@didio.com.au"],["Stevie","Hallo","Landrum Temporary Services","22222 Acoma St","Proston","QL","4613","07-9997-3366","stevie.hallo@hotmail.com"],["Mariko","Stayer","Inabinet, Macre Esq","534 Schoenborn St #51","Hamel","WA","6215","08-5558-9019","mariko_stayer@hotmail.com"]]'; $page->of(false); // Turn OutputFormatting of $page->fieldname->json = $json; $page->save(); $page->of(true); API Side (CSV): // CSV string $csv = '"First Name","Last Name","Company Name",Address,City,State,Post,Phone,Email Rebbecca,Didio,"Brandt, Jonathan F Esq","171 E 24th St",Leith,TA,7315,03-8174-9123,rebbecca.didio@didio.com.au Stevie,Hallo,"Landrum Temporary Services","22222 Acoma St",Proston,QL,4613,07-9997-3366,stevie.hallo@hotmail.com Mariko,Stayer,"Inabinet, Macre Esq","534 Schoenborn St #51",Hamel,WA,6215,08-5558-9019,mariko_stayer@hotmail.com'; $page->of(false); // Turn OutputFormatting of $page->fieldname->csv = $csv; $page->save(); $page->of(true); After save, all other subfield are updated. So saving JSON will update CSV and the rows and the columns. And saving CSV will update JSON and the rows and the columns. Saving direct to the fieldname, or saving to both json and csv or saving to the rows & columns wil thow a wireException(). Download: source on github Warning: This Fieldtype is Álpha, don't use it in live projects empty field: paste data: imported data: manage data: settings:
    1 point
  7. Just as I always was thinking "you can find anything on the internet" - why need it? But a member of this community (don't know if I can say the name) was so kind to arrange for me to follow a php course. And I must say "1 day has given me so much more tips which I consider to be gold"! Array, loops, strings, operators, and more. Never knew there were so many things possible in the right context... I really like the way it is explained, for instance the =, == and ===. Or even the ' ' and " " differences.
    1 point
  8. ProcessWire ProFields is new product that will soon be available in the ProcessWire store. It consists of 4 really useful new modules: Textareas (Fieldtype + Inputfield) Multiplier (Fieldtype + Inputfield) Table (Fieldtype + Inputfield) AutoLinks (Textformatter) These modules are currently in beta testing, and I'll be posting screencasts to highlight some of the features of each over the next week or so. To start with, here is a screencast for Textareas: This video includes sound (narration) and I recommend viewing it at a larger size than above (preferably full screen), and bump it up to the 720p resolution so that you can see everything in better detail.
    1 point
  9. I believe ID base urls have very good uses though they may not be suitable for most projects. I do have a few projects where being able to access the unique Page ID is beneficial. Why should we have to create a new unique identifier when ProcessWire already has a built-in one? The great thing about ProcessWire is that there are a multitude of solutions available. You are not forced to work in a particular or limited way.
    1 point
  10. I have a browse.php template which includes certain layout. For my parent (field select) pages as well as their children I use the same layout. But for members browsing I use another layout. So 1 template, 2 includes. Using my first function (post on top) I did not really know how to implement the members code. But then I started follow a course and hence: Just to make my function selector look more nice I used switch() - learned in PHP course. Hope you guys like my efforts: function selects(){ // set required variables; $page = wire("page"); $pages = wire("pages"); $noresult = wire("config")->urls->root; $layout = "browse.inc"; switch ($page->id) { case '1006': case '1008': case '1026': case '1077': case '1127': case '1138': case '1156': // cases up until here have same selector, e.g. parent field select $selector = "template=child-template, limit=4, sort={$page->name}"; break; case '1171': // this case is for members, selector and include layout change $selector = "roles=member|employer|applicant"; $layout = "members.inc"; break; default: // this is the default if none of the cases match, e.g. children field select $selector = "template=child-template, {$page->parent->name}={$page->id}, limit=4, sort=-{created}"; break; } // construct what we are selecting. Now I do not have to use $selects = $users->find($selector); $selects = $pages->find($selector); // we output something else if nothing is there if (!count($selects)) { return "<div class='medium-12 columns'><h3>No items are found.</h3> <p>try searching through our indexes at <a href='{$noresult}'>ClientC</a> or use the search form on the right.</p></div>"; } else { // construct quantity found $message = "Showing {$selects->count} out of {$selects->getTotal()}"; // contruct pagination $pagination = $selects->renderPager(array( 'listMarkup' => "<ul class='MarkupPagerNav pagination'>{out}</ul>", 'currentItemClass' => 'current' )); // call layout for results: display quantity, paginator, foreach, and markup include($layout); } }
    1 point
  11. Love your post Teppo - it did make me wonder if there should be an official blog on this site if certain folks would be willing to post to it? I used Google Translate on that article above Antti - some amusing mis-translations I think by Google (such gems as: "ProcessWire does not matter by itself", "So there is no overhead - but you can also get paid nothing") but I got the idea and it was a nice, positive and concise assessment.
    1 point
  12. Still had to report back... Everything works as expected... thank you for that! Regards!
    1 point
  13. Best tutorial: http://codebabes.com
    1 point
  14. First off I don't think loaded is the right place to hook. Page::loaded is (I think) when a page is loaded but not have to be a rendered/viewed. It will in a autoload module also execute in the admin. Second is you with addHook("Page::loaded" you add a new method, but it seems it would also work but better is addHookBefore addHookAfter Next would be the exit() in such a hook is most of the time not a very good idea, it will just stop any code that may come after your hook. I tried your hook and get a similar error. Not looking further into why. To hook into after a page was viewed/rendered you should hook into ProcessPageView::execute or Page::render public function init() { $this->addHookAfter('ProcessPageView::execute', $this, 'pageViewed'); } public function pageViewed(HookEvent $event){ $page = wire("page"); if ($page->template == 'basic-page') { $page->headline = 'Something'; $page->save(); } } ProcessPageView.module handles the viewing of a page on front-end Since the ProcessPageView modifies/sets the current $page before rendering, you can get the current viewed page with wire("page"); So since you get the page this way you also don't need to set output formatting false. public function init() { $this->addHookAfter('Page::render', $this, 'pageRendered'); } public function pageRendered(HookEvent $event){ $page = $event->object; if ($page->template == 'basic-page') { $page->of(false); $page->headline = 'Something2'; $page->save(); } } This does the same just with a hook after page being rendered. The current page can also be get through the hook event object. And since it is rendered there's output formatting on. So we set it to false here $page->of(false); NOte the Page::render() isn't found in Page.php but wire/modules/PageRender.module and it's added by a method hook in that module.
    1 point
  15. Can WillyC do the sub titles then ?
    1 point
  16. Regarding languages for these modules, I don't see language alternative fields (ie: text, text_fr, text_it) being avery usable option. Consider having 5 text inputs, I have to create one field for each language and put them all one after another, that will give me 3x5 inputs scattered over the page editor. For site editors this doesn't feel quite intuitive and is mixing approaches. So creating 5 textfields is still the best way to go and those profields aren't of much usage except for multiple inputs not needing languages like phone numbers, which is very seldom. EDIT: Regardless, I also wanted to say thanks for those amazing nice new tools! (just wish that "restriction" regarding languages wasn't there).
    1 point
  17. @ceberlin, Thank you for letting me know. Could you try changing that line to... if (isset($this->data['debug'])) { ... and let me know if that solves the issue for you.
    1 point
  18. Hi Ko7n it's heredoc syntax, one way of writing PHP to save having to go in and out http://www.php.net/manual/en/language.types.string.php#language.types.string.syntax.heredoc
    1 point
  19. I've been seriously researching the options for digital products (e-goods) since we have several record label clients running stores that sell music downloads, and we're attempting to migrate away from Joomla, where we have been using a component for this. So far my experience with Ecwid has been great - the pricing is very reasonable, they have a free plan, and everything seems to work well; For e-goods, you get 100 products, unlimited storage and bandwidth for $15/month. The only issue is the 100MB max on the filesize, but there are ways around that, such as splitting large files into multi-part archives, however this can be less than convenient for the end user than just getting the complete file. Ecwid integration with processwire is nothing; the only thing that could get tricky involves the SEO with ajax, and they have instructions for how to get this setup right; Most people would have a separate page for each product in PW anyway, so that wouldn't be an issue. the other e-goods options I have looked at include: http://www.fetchapp.com https://gumroad.com/ http://quixly.com/ http://pulleyapp.com/ Fetchapp's pricing (http://www.fetchapp.com/pages/plans) can't really compete with Ecwid, unless you use the $10 "use your own server" plan, and then host the files on s3. I think one advantage of fetchapp is that it can host larger files without breaking them up; The only other thing is that Fetchapp is digital goods only, while Ecwid can do both digital and physical.. Gumroad looks cool- there is no monthly fee, and you don't need to have a payment gateway, like PayPal... this article was kind of helpful... http://www.smashingmagazine.com/2012/03/29/selling-digital-goods-online-e-commerce-services-compared/ -marc
    1 point
×
×
  • Create New...