Jump to content

gebeer

Members
  • Posts

    1,386
  • Joined

  • Last visited

  • Days Won

    39

Everything posted by gebeer

  1. Not sure if you can achieve this all with one $pages->find operation. You'd have to loop through the items and separate them into 2 page arrays (viewed yes and viewed no). $items = $pages->find("template=item, sort=-created"); $notViewed = new PageArray(); foreach($items as $item) { if ($item->children("viewed_by!={$user}")->count()) { $notViewed->add($item); $items->remove($item); } } The $notViewed PageArray should hold all items where at least one note has not been viewed yet. $items should only contain the items where notes have been viewed by the user since we removed the other ones inside the loop. Now you can loop through $notViewed and $items to display them.
  2. My pleasure. If you set a page field to multiple pages and you only have one value you could get that with <?=$program->computer->first()->title?>
  3. In the field settings for your computer page field, is this field set to hold multiple pages or a single page?
  4. Thank you all for your help on this one. @szabesz I would rather not like to install Trasy Debugger if there was a simpler method through the API @LostKobrakai the suggested code returned null. But this version (with parentheses appended to the getQuery method) works: wire('pages')->getPageFinder()->find(new Selectors($selector), array('returnQuery' => true))->getQuery(); It returned exactly the query I was looking for SQL_CALC_FOUND_ROWS pages.id,pages.parent_id,pages.templates_id FROM `pages` JOIN field_id_gc AS field_id_gc ON field_id_gc.pages_id=pages.id AND (((field_id_gc.data='16800' ) )) JOIN field_timestamp AS field_timestamp ON field_timestamp.pages_id=pages.id AND (((field_timestamp.data>='2016-01-28 15:00:42' ) )) JOIN field_timestamp AS field_timestamp1 ON field_timestamp1.pages_id=pages.id AND (((field_timestamp1.data<='2016-02-16 00:19:53' ) )) LEFT JOIN field_timestamp AS _sort_timestamp ON _sort_timestamp.pages_id=pages.id WHERE (pages.templates_id=44) AND (pages.status<1024) GROUP BY pages.id ORDER BY _sort_timestamp.data LIMIT 0,100 @kongondo $queries = $database->getQueryLog(); returns an array of queries with a lot more info than LostKobrakai's code and the specific query is not included. The querie here look somewhat like the output of Debog Mode Tools in backend.
  5. Hi, you can find some basic search logic in the search.php of the default site profile: https://github.com/ryancramerdesign/ProcessWire/blob/master/site-default/templates/search.php In https://github.com/ryancramerdesign/ProcessWire/blob/master/site-default/templates/_main.php#L61 you find the code for the search form. This should get you started. EDIT: If you should later decide to use AJAX, there is Soma's module: https://github.com/somatonic/AjaxSearch
  6. Another way could be: When automatically creating the userpage in your hook, you can set wire('page')->created_users_id = wire('user')->id Now the page is owned by that user. When the user logs in to lets say .../userpages, in the template.php for userpages you can get the user's page with $pages->get("template=userpagetemplate, created_users_id={$user->id}") To be able to change the user of a page, you need to enable this in the template settings for the userpage-template in the Advanced tab towards the bottom.
  7. If 'user' is the name of your page field that holds the users, try <?=$device->user->name?> or <?=$device->user->title?> // if you have a title field in the user template This works only if the user page field is set to hold only one page.
  8. Hello, How would I get the DB query that is used to gather the data for something like wire('pages')->find("template=log, id_gc={$serverId}, timestamp>={$dateStart}, timestamp<={$dateEnd}, sort=timestamp"); Tried using the Debug Mode Tools in the backend on a lister with similar selector. But I couldn't make out the right query in there. I'd like to use that query directly to dump data from the DB to a csv via SELECT INTO. Processing 10.000s of pages in chunks of 100 via the API into a csv. This is quite time consuming (several minutes for ~20.000 pages that result in a ~13MB csv file). Any help would be much appreciated.
  9. Thank you nik, for that code. I am using it and it works quite well. Only thing that needs to be changed is the while from while (count($results) > $limit); to while (count($results) = $limit); Otherwise it loops 1 more time than it should.
  10. 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.
  11. @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.
  12. @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.
  13. 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?
  14. @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}");
  15. @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).
  16. @kongondo I am all for number 1 as I am pretty sure that people are willing to pay for such a feature rich module.
  17. 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; } }
  18. Why not make this a community funded module? I'd be more than happy to contribute to financing it.
  19. 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")
  20. One of those hidden beauties that would be great to have them in the Cheat Sheet...
  21. 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.
  22. 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.
  23. 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
  24. 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.
  25. 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?
×
×
  • Create New...