Jump to content

gebeer

Members
  • Posts

    1,554
  • Joined

  • Last visited

  • Days Won

    48

Everything posted by gebeer

  1. Hello tewdin and welcome to the forum! From your description I don't really get what you want to do exactly. Are you talking about the frontend or the admin area of your site? In the frontend, if you only want to show pages to a user that "belong" to that user (were created by that user), there is $page->createdUser or in a selector created_users_id. So to select only pages that were created by the logged in user, you can do $pages->find("created_users_id={$user->id}"); To redirect non logged in users: if(!$user->isLoggedin()) $session->redirect($pages->get("/login/")->url); Hope this helps to get you started.
  2. @bernhard actually this is a long ongoing project which is already online. I am constantly implementing new features. But the project is hard to showcase because most of the stuff happens inside a frontend member-area which requires login. I have been planning to showcase this for some time now and I might go with screenshots. But ATM I do not have the capacities to document it thoroughly. Though this might happen at some point, I can't tell when. Anyways, feel free to use the code for the Survey Builder in the plunk that I linked to. I will implement that as a PW module for the project and will share that module once it is up and running.
  3. @tpr thanks for the insight and for your offer. I don't think I really need that code @kongondo thank you for your confirmation on textarea being a good chopice for JSON storage and for the other considearations 1 page per poll because here I only store the JSON that is produced by the survey builder and will be used to render the poll form. The submitted poll results will be sent to a different PW install and stored there. There I will store poll id and for each user submission the question/answer ids in a table pro field. Later I can pull this data, analyse it and present it in graphs using t3 library. Example: -parent page poll --child page question1 ---child page answer1 ---child page answer2 --child page question2 ---child page answer1 ---child page answer2 I'm more after 'Drink A tests better than drink B'. So I will store the submitted results like described above.
  4. Hi Folks, I am currently building an angular app for creating and displaying polls/surveys: http://embed.plnkr.co/seQfprxQRvjg84bvi2Dy/ The data that needs to be stored in PW comes from JSON and looks like { "title": "My Survey", "questions": [ { "id": 1, "title": "First Question", "answers": [ { "id": 1, "title": "Answer 1" }, { "id": 2, "title": "Answer 2" } ] } ], "file": { "$ngfName": "long-beach-koh-payam.jpg", "$ngfOrigSize": 351901, "$ngfBlobUrl": "blob:http://localhost:8000/8b87de97-549a-4900-8579-71a0d87a9258" } } Now I need to decide how to best store that data with PW. I am also using Angular to build the forms where users can submit the poll from the JSON that is produced by the survey builder. So I would like to create 1 page per poll. The template holds title field, an image file field and one field that stores the data as JSON string. To me this seems an easier approach than having child pages for each question in the poll and again child pages for each answer to a question. Do you see any disadvantages that this approach might bring? And which field type should I use to store the JSON string, textarea?
  5. @houseofdeadleg sorry, I don't have the capacity to look into this thoroughly at the moment. I'll try and implement it like described in #11 within the next few weeks. The unterminated string literal error often happens when strings with line breaks are used in JS variables. So we might need to account for that in the $options["markerPopupContent"] string when passing it to the javascript. Try using $options["markerPopupContent"] = json_encode("<b><a href='{$page->url}'>{$page->title}</a></b>{$page->body}");
  6. @Asmordean You might want to have a look at https://github.com/mozilla/pdf.js Widely used code for embedding PDFs in a standards-friendly way. As szabesz said, you still need to check for the client's browser setup and act accordingly if you want to make sure that the PDF is embedded in your HTML. Here's some code to point you in the right direction: https://gist.github.com/falexandrou/9753871 Instead of using an Iframe you could embed it as an object (see the first link above).
  7. @kongondo I am all for number 1 as I am pretty sure that people are willing to pay for such a feature rich module.
  8. I am getting the same error with multi language fields when I use getLanguageValue method. When I use the other approach it is working. Try this $categories = $pages->get(1060)->children(); $language = $user->language; // save the user's language foreach($categories as $category) { $user->language = $languages->get('default'); // you need to use default because English is your default language and set the $user language to it $content .= $category->title; } $user->language = $language; // restore the user's language If you want to show page titles in all languages, just loop through your languages inside the foreach: foreach($categories as $category) { foreach ($languages as $lang) { $user->language = $lang; $content .= $category->title; } }
  9. Why not make this a community funded module? I'd be more than happy to contribute to financing it.
  10. Don't know about performance, but with this code you would set the value of $my_page_array to 1234 which most likely would throw an error. For comparison use $my_page_array === 1234 If you have the $page object that you are searching for already, you can also pass that directly into the has() method like $my_page_array->has($page) instead of $my_page_array->has("id=1234")
  11. One of those hidden beauties that would be great to have them in the Cheat Sheet...
  12. You need to create a file /site/modules/InputfieldCKEditor/contents.css with the styles you want to apply inside the Editor. And have a look at /site/modules/InputfieldCKEditor/README.txt on how to activate it: contents.css ============ Example CSS file for the admin editor. To make CKEditor use this file, go to your CKEditor field settings and specify /site/modules/InputfieldCKEditor/contents.css as the regular mode Contents CSS file.
  13. This might be related to the directory traversal setting in AIOM. I stumbled over this once. Thank you for this hint. I wasn't aware of it.
  14. I can confirm that it works for put requests. For patch/delete, I'm sorry, but I can't confirm because I havent used them. If you get an empty $params, this may have 2 reasons: 1. you did not specify the header Content-Type application/json 2. the JSON in the request body is malformed
  15. To expand on arjen's answer: I had use cases where I had to add more than one tab to several templates. To avoid creating too many individually named fields of type FieldsetTabOpen, I did the following: Create fields of type FieldsetTabOpen with generic names, like tab1, tab2 etc. Apply the field to template A and in the template override for the field label name it e.g. "Sidebar Left" Apply the same field to template B and in the template override for the field label name it e.g. "Sidebar Right" This way you only have one field of type FieldsetTabOpen but can use it for differently named Tabs in different temp[lates.
  16. I can confirm, that put is working. All JSON that I send in the request body is available in $params. For patch/delete, I'm sorry, but I don't know because I haven't used them. If $params is empty: did you make sure that header Content-Type application/json is set? Or maybe the JSON in your request body is malformed?
  17. I am not sure about passing variables to field->renderValue. But adding your JS and CSS dependencies to custom arrays is pretty straightforward. In config.php you can define your custom JS and CSS arrays like $config->customJs = new FilenameArray; $config->customCss = new FilenameArray; Then in your template file where you want to include your dependency you do $config->customJs->add('pathtoyourscriptfile'); $config->customCss->add('pathtoyourstylefile'); In the head section of your html you then render them with <?php if(count($config->customCss)) foreach($config->customCss->unique() as $file) echo "\n\t<link type='text/css' href='$file' rel='stylesheet' />"; ?> and in the head or end of body section render your JS <?php foreach($config->customJs->unique() as $url) echo "<script src='$url'></script>"; ?>
  18. Hello Mission and welcome to the forum! Do you have any custom code where you deal with database connections or does this happen on a clean install of PW? And what is your hosting provider/setup (shared hosting)?
  19. Looking again at my above implementation for additional content in the marker popup feels a bit hacky because the content of the popup is being constructed in MarkupLeafletMap.js I think the cleaner and proper way of doing it would be to construct the HTML that goes into the popup on the template file level and then pass it to the map render function. Something like this: $options = array(); $options["markerPopupContent"] = "<b><a href='{$page->url}'>{$page->title}</a></b>{$page->body}"; // ... more options $map = $modules->get('MarkupLeafletMap'); echo $map->render($items, 'map', $options); Hope to get your opinion on this. I would then implement the code into my fork of this module.
  20. Since browser support for flex is now pretty good, I am looking into using flexboxgrid. It looks very promising and looking at their github repo with all those likes and forks it sure will last. Has anybody here used it and what do you think?
  21. @houseofdeadleg At the moment only the title is supported. You would need to change some code in the module: https://github.com/madebymats/FieldtypeLeafletMapMarker/blob/master/MarkupLeafletMap.module#L115 -> add another line 'markerBodyField' => 'body', https://github.com/madebymats/FieldtypeLeafletMapMarker/blob/master/MarkupLeafletMap.module#L192 -> add another line $body = $options['markerBodyField'] ? $page->get($options['markerBodyField']) : ''; https://github.com/madebymats/FieldtypeLeafletMapMarker/blob/master/MarkupLeafletMap.module#L193 -> change line 193 to $out .= "$id.addMarker($marker->lat, $marker->lng, '$url', '$title', '$body'); "; https://github.com/madebymats/FieldtypeLeafletMapMarker/blob/master/MarkupLeafletMap.js#L65 -> change line 65 to this.addMarker = function(lat, lng, url, title, body) { https://github.com/madebymats/FieldtypeLeafletMapMarker/blob/master/MarkupLeafletMap.js#L98 -> change line 98 to marker.bindPopup("<b><a href='" + marker.linkURL + "'>" + title + "</a></b><br>" + body); Then in the template where you render the map, you need to include the markerBodyField in the options that you pass to the render function, e.g. $options = array(); $options["markerTitleField"] = $page->title; $options["markerBodyField"] = ($page->body) ? $page->body : ""; // ... more options $map = $modules->get('MarkupLeafletMap'); echo $map->render($items, 'map', $options); I have not tested this but it should work. Please report back here.
  22. @horst you could also use the (relatively) new $sanitizer->int($value) or $sanitizer->intUnsigned($value) method like if(wire("sanitizer")->int($input->get->id)) {...}
  23. @Alxndre' I can see an advantage using $params: it utilizes a standardised way of sending data through the request body in a JSON object. So there is only one place where you have access to all the data that was sent with the request. Also, if you do basic http authentication and use my modified version of the helper classes, you will have access to $params["name"] and $params["pass"] to do request validation.
  24. @alan do you get <li> instead of <fieldset> tags? That would be the default behaviour. You can set the HTML tags that are rendered, even by inputfield type, see here.
  25. It would be fantastic if we could set different configurations for CKEditor fields based on template or user roles. Like described on https://weekly.pw/issue/14/ under "More CKEditor upgrades", we can use config files in /site/modules/InputfieldCKEditor/ to store settings per field. E.g. for the body field this would be /site/modules/InputfieldCKEditor/config-body.js. Maybe this logic could be extended to something like /site/modules/InputfieldCKEditor/config--field-body--template-home--role-mycustomrole.js. I was coming over from Joomla to PW couple of years ago and there we had an excellent CKEditor integration called JCE where you could define settings per user role etc. Maybe I am wrong but up to now we need to create additional fields if we need editor config settings per template. If there already is a way to do that I'd be happy to know.
×
×
  • Create New...