Wanze
PW-Moderators-
Posts
1,116 -
Joined
-
Last visited
-
Days Won
10
Everything posted by Wanze
-
Simplest solution may be this: <?php $ul = str_replace('<ul>', '<ul class="half">', $page->finplan_assistance_list_items); echo $ul; ?> You could also set the class with javascript. Or copy the Textformatter module from /wire/modules/ in /site/modules/ - give it a new name, modify the code to your needs, install and use it.
-
Hi daniel (right?) I think you may want to check out ryans "Newlines to Unordered list" textoformatter module. This module converts newlines entered in a textarea to a list in your frontend. It ships with the core but is not installed by default. Go to Modules > Textformatter > click Install Now on your textarea field, go to the Details tab and choose this textformatter.
-
how to retrieve repeater Id and export it to JS (gallery)
Wanze replied to wishbone's topic in Getting Started
$pages->get($name_of_repeaterfield); What does $name_of_repeaterfield contain? -
Hi teppo, Thanks. This is very interesting, I didn't know mPDF before. Looks very promising if the html support is better plus the whole library is very lightweight compared toTCPDF. TCPDF and also mPDF are both extensions of FPDF. Some years ago, I used FPDF but the problem there is the missung UTF-8 and HTML support. As most of the libraries seem to depend on FPDF, this now has the advantage that one could easily exchange the library behind the module without changing much code. Looking forward to your feedback!
-
Thanks people, Please report feedback or ideas for further improvements. Yep. The pdf is generated from a ProcessWire template in /site/templates/pages2pdf/. Think of it as a normal Pw template: You can use $page, $pages, $users and all other variables to search and output your content. The only restriction is that you have limited html support, so make sure you use supported html tags in TCPDF (see link in first post). There's also another module which generates pdfs from the Admin: http://modules.processwire.com/modules/pdfcomposer/
-
I didn't realize that there was already a pdf module. Looks like Pdf Composer is a Process-module which generates pdfs of one or more pages, while Pages2Pdf is meant to be used in the frontend.
-
Hi andyrak, Thanks! Looks like the Page::of() method (shortcut for setting outputformatting) does not exist in Pw 2.2.0. Can you update your ProcessWire installation to the current stable or dev version? I think this should fix it for you.
-
You can catch exceptions before Pw does, but I think the problem with your code is the include. Try writing the 'try' and 'catch' block inside your $file. In a project I have to import users with a cronjob and I'm doing something like this: try { $user->save(); } catch (Exception $e) { //.. write a Log with the Exception }
-
How to hook into comments module to change notificationEmail?
Wanze replied to apeisa's topic in General Support
LOL -
Hi, After reading this thread, I decided to make a module that helps generating PDF files of ProcessWire pages. GitHub: https://github.com/wanze/Pages2Pdf Modules Directory: http://modules.processwire.com/modules/pages2-pdf/ This module uses the mPDF library to generate the PDF files. It has fully UTF-8 and basic HTML/CSS support for rendering the PDF files. The output is customizable with ProcessWire templates. Example I've enabled generating PDF files for the skyscraper template of ryans Skyscrapers-profile with a template that outputs the data in a table along with the body text and the images: one-atlantic-center-pdf-4177.pdf Please take a look at the README on GitHub for instructions and further information/examples. Cheers
- 343 replies
-
- 33
-
Is there any way to execute PHP loaded from textarea fields?
Wanze replied to DZoneRick's topic in API & Templates
But you know that with Tinymce and soon also with the brand new CkEditor you can insert images from the images field into your html markup? (http://processwire.com/talk/topic/627-ckeditor-module/page-2) There's also a Youtube-video Textformatter by ryan. Just copy the Youtube-url inside and it gets replaced with the video. If you have content-editors that understand html/css etc, you could use only a richtext/image field and write the complete markup there. However, this is not a good solution for most of the editors because they can mess up the entire design. It's safer to split things up in different fields (headline, description, body, images, files, related_posts etc.). This way ou can also easy change the whole markup afterwards. -
Uploading a new photo to a member profile avatar field?
Wanze replied to FuturShoc's topic in Getting Started
But that's another error now Are you on Pw 2.2.9? Grab the latest dev version or just the Upload.php class from there, I think the "setMaxFileSize" method was added later. -
Is there any way to execute PHP loaded from textarea fields?
Wanze replied to DZoneRick's topic in API & Templates
The possibilities are endless in Pw to achieve what you want. Some Possibilities: Don't use $page->title but $page->id instead - this id is unique even if you change the title Better: Give the pages you need the additional js the same template => this way you only have to check for the template Add a checkbox field to the template(s) of pages that need the additional stuff and check if this is set If you really, really need to access the templates url from inside a textarea, you could do something like this: //in Textarea blu blu blu {{templates}} blub blub blub //In template $blub = str_replace('{{templates}}', $config->urls->templates, $page->blub); @pwired What? In Pw your fields ARE the template variables, just more flexible. Who stops you from adding html/css/js into a textarea field in ProcessWire? -
Uploading a new photo to a member profile avatar field?
Wanze replied to FuturShoc's topic in Getting Started
Then you still mix up the variables of the user and the WireUpload class. The error message clearly says that no method "of" exists in WireUpload. This error appears because you are trying to execute WireUpload::of() $f->of(false); //Wrong! $u->of(false) $u->avatar = $upload_path . $files[0]; $u->save(); $f->of(true); //Wrong! $u->of(true); Also make sure that your user was found: if (!$u->id) { //.. no User found! } -
Hi LeiHa, As far as I know, it's currently not possible to have Asian letters in the url. ProcessWire accepts only the characters mentioned in the description. This restriction is already fix in the .htaccess. Any url that doesn't match the criteria isn't routed through Pw: # ----------------------------------------------------------------------------------------------- # Ensure that the URL follows the name-format specification required by ProcessWire # ----------------------------------------------------------------------------------------------- RewriteCond %{REQUEST_URI} "^/~?[-_.a-zA-Z0-9/]*$"
-
Marty, I think you could set the outer tpl to an empty string and add the ul-tags and your page manually: <?php $customPage = $pages->get('/.../'); echo "<ul>"; echo "<li><a href='{$customPage->url}'>{$customPage->title}</a></li>"; //Add your entry above all others echo $modules->get('MarkupSimpleNavigation')->render(array('outer_tpl' => '')); echo "</ul>"; Not tested and just an idea, maybe Soma has a better solution Cheers Edit: Damn I need to get some sleep NOW
-
Uploading a new photo to a member profile avatar field?
Wanze replied to FuturShoc's topic in Getting Started
There's a nice class WireUpload that makes uploading files very easy. Here a slightly modified example of a site: $upload_path = 'YOUR_TEMP_UPLOAD_PATH'; $u = new WireUpload('avatar'); //avatar is the name of the input-file field $u->setMaxFiles(1); $u->setMaxFileSize(5*1024*1024); $u->setOverwrite(false); $u->setDestinationPath($upload_path); $u->setValidExtensions(array('jpg', 'jpeg', 'png', 'gif')); $files = $u->execute(); //Actually not sure if this returns an array if you only allow to upload one file, maybe its the filename (string) if ($u->getErrors()) { foreach($files as $filename) @unlink($upload_path . $filename); foreach($u->getErrors() as $e) echo $e; } else { //Save the foto to the avatar field $page->of(false); $page->avatar = $upload_path . $files[0]; $page->save(); $page->of(true); @unlink($upload_path . $files[0]); } As you can see, it's very straightforward to add the image to the avatar field (Pw rocks!) -
Wow this is awesome news ryan! I will help to test for sure! First answers from 3 swiss guys - no surprise because we have 4 languages in Switzerland and therefore lots of websites need to be multilingual
-
Thanks for your feedback! Yeah at the moment the module still is a tool for Superusers or users with at least some technical knowledge how the Selectors work. In a next version, I will try to set up some sort of predefined search queries where you can define a title, selector and (optionally) a user-role. Instead of writing a query with the selector, a list of links is displayed that execute the search behind the scene. Extra filters: I think it's not possible to filter pages by locked or published with a selector. There exists only "include=all" which includes hidden, locked and unpublished pages. And then also "include=hidden", which includes only the hidden pages. Not sure about your third point, the pages you get can be sorted in any possible way. To see parent-child relationships it's better to look at the page tree. Sorry I forgot too. Actually I didn't look at your code because I wanted to learn how everything works by myself. But the UI is inspired by your module of course Will stop by in the IRC sooner or later! Thanks for the feedback. First I had the titles as links, but it didn't look nice. At least not with the default-theme and most others. It's also not the purpose of the module to edit each page separate, so I thought the link shoud not be "too" big. True. I do a redirect with $session to prevent "double executing" of stuff. Maybe that's not really necessary, I'll figure out a solution for the next release.
-
You can define the fields that are displayed as columns in the table in: Modules > ProcessUser But I think the status is not possible to display this way.
-
Get Pages with the most similar Categories (sorted)
Wanze replied to dreerr's topic in API & Templates
Maybe: $categories = $page->categories; $relatedVideos = $pages->find("template=video, categories={$categories}"); //Don't know 100% if this is possible with pw: $relatedVideos->sort("-categories.count"); foreach ($relatedVideas as $v) { //..print } //If the above does not work, add the videos to an array and sort this with PHP's ksort $videos = array(); foreach ($relatedVideos as $v) { $videos[count($v->categories)] = $v; } //Sort array by keys ksort($videos); //Access the keys in reverse order $count = count($videos)-1; for ($i=$count; $i>=0, $i--) { //..print } Does it work? -
Or if it needs to be created server-side, a standalone module that takes the Pageimage object as argument and simply returns the url to the greyscale image: $greyscale = $modules->get('Greyscale'); $greyscaleImage = $greyscale->execute($image); //$image would be the Pageimage object echo "<img src='{$greyscaleImage}' alt=''>
-
Hi arjen, You must give your editor role this permission : "Administer users (role must also have template edit access)". + the Editor needs edit permission on your User template. Can the editor see the users now if you move the Page outside of "admin"?
-
Ah very nice some thanks Soma, know I know what $event->object is I know that Hooks are awesome but have not really figured out how everything works behind the scenes. ProcessWire is the best real life example in terms of Software Design Updated my first post. But what if I actually want a new image generated and not modify the existing Pageimage object? I could clone the $img and then return the "new" Imagesize object, like in my post above. But this would need some checking if a greyscale image already exists and in this case don't filter again.