Jump to content

sins7ven

Members
  • Posts

    26
  • Joined

  • Last visited

Recent Profile Visitors

2,161 profile views

sins7ven's Achievements

Jr. Member

Jr. Member (3/6)

6

Reputation

  1. Thank you very much! Now it works! Just to add on to this. It also works with the "each" method. Like so: "socials" => $m->socials->each(["link"])
  2. Hi community, I am trying to build a way to create some JSON output for some pages. For this I created a template called json.php. This one has URL segments enabled and based on this it gives me some page data. I mostly use this for getting some JSON into my JS libraries (like Vue.js) to build some interactive filters. So for example www.domain.com/json/referenzen should give me all data from the clients child pages (usually logo references). This works totally fine. But for one special case (getting management child pages) I have a repeater item on each page and I am not sure how to get this repeater item into my JSON data. My code looks as follows: <?php namespace ProcessWire; if (!$input->urlSegment1) { $session->redirect($pages->get('/')->url); } $data = array(); switch ($input->urlSegment1) { case "referenzen": $p = $pages->get("name=referenzen"); foreach ($p->logo_select as $logo) { $data[] = array( "name" => $logo->title, "url" => $logo->image->url, "category" => $logo->business_category->value ); } break; case "management": $p = $pages->get("name=management")->children; foreach ($p as $m) { $data[] = array( "name" => $m->title, "venture" => $m->venture_select->title, "image" => array( "url" => $m->image->url, "description" => $m->image->description ), "position" => $m->team_details->position, "email" => $m->team_details->email, "phone" => $m->team_details->phone, "socials" => $m->socials // This is the repeater item which has links to social networks ), ); }; break; } header("Content-type: application/json"); echo wireEncodeJSON($data); return $this->halt(); ?> I know there are some modules like Pages2JSON or PageQueryBoss but I thought I could solve this without extra need of a module. Would be nice if someone could point me into the right direction. Thanks!
  3. Thanks a lot Dragan, but this is something I am already aware of and my problem is a bit different. Please see the image here as an illustration example. It is more a matter of rearranging the order within each language. So when I just sort by the language tag it just outputs all the logos that have this particular language tag but not in a specific order as I would set it in the backend with drag and drop of the gallery items. But I assume this could also be done with some tags. Just creating some tags (first, second, third etc) and assigning them as well to the tags so they would appear before the other ones that do not have one of these "priority" tags?
  4. Thanks Dragan, that is something I already considered but this would not solve the issue about sorting and displaying the images in a different order based on the language.
  5. Hi Processwire Community, I am wondering if its possible to change the order of an image gallery based on the language. I have the following use case. A multi-language website (german, english, dutch). These are business websites and they show some clients logos. Now basically this would just be an issue of using the image field and getting all images in one and iterating over them to generate the output. Now how would it be possible to change the order of how they appear based on the language? Let's say for the german site I want some logos to appear much earlier than for example on the dutch site. Is that possible? I found some forum entries about language alternate fields so which would basically mean I need to set up 3 different fields (gallery, gallery_english, gallery_dutch) to make it possible to set different sort orders of the logos? But wouldn't this also mean I basially end up having 3 versions of each logo/image on my page? Or is there another way to achieve this? I was also thinking about creating a repeater field for each image so I can add some more properties to each image (e.g. a category so I can later use some Javascript to build some nice category filters). So in regards to my example above I would need 3 different repeater fields (e.g. gallery_repeater, gallery_repeater_english, gallery_repeater_dutch) to get this working, right? How much impact does that have on the performance, assuming I have something between 40 and 50 logos to display (which would basically mean 40-50 repeater items per language).
  6. Thank you! That looks pretty close to what I have in mind. However - I am not sure if this approach let me allow only some selected languages to be available in the language switcher (for example domainA.com should only show default and english and domainB.com should show default, french and dutch). But I am not sure if it is even possible to change the default language based on the host? I am going to play around with your solution and see what I can achieve. Thanks again!
  7. Hi community, I am wondering if its possible to display languages based on what host/domain has been requested. The use case is the following: I have one installation of PW - and within this installation I set up 5 different languages (default, english, spanish, french, dutch). Now I have 3 different domains (domainA.com, domainB.com, domainC.com) and I want to decide which languages to make available based on what domain has been navigated to. For example: domainA.com - default (domainA.com) - english (domainA.com/en) domainB.com - default (domainB.com) - french (domainB.com/fr) - dutch (domainB.com/nl) domainC.com - default (domainC.com) - dutch (domainC.com/nl) So what I want to achieve is making only these particular languages selectable in the language switcher on the frontend. Since all pages share the same templates and overall site structure I don't see the benefits of running this installation as a multisite setup or would it be better to do so? But I assume that this would be difficult to handle since the default language might change as well. (On the french version of the page, french should be the default language and so on). Any suggestions how to accomplish that? Thanks!
  8. Thanks a lot for your input guys. I didn't know about the possibility to do this also with a dashboard in the admin area but I think I will go with the frontend route this time as there is really only showing and displaying content and not letting the users create or modify anything.
  9. Hi community, I have been thinking about a project lately and was wondering if this is something I can accomplish with Processwire. I know the platform is pretty much capable of getting everything done but tbh I am not sure on this one. I want to create a site which only has a login. The logins and details are pre-made and been sent to the user before. So there is no need for registration. After the login, the user can see his own kind of dashboard and a dropdown where he can select "projects". Each project has a number of properties or data values, for example: Project 1: - time to finish: 30 days - time spent: [amount per user] - project budget: 100.000 $ - money earned per user: [amount per user] Project 2: - time to finish: 40 days - time spent: [amount per user] - project budget: 50.000 $ - money earned per user: [amount per user] The fields are just an example. The goal is to assign users to the projects and set the value as per example above so when the user sees his dashboard and selects a project from a dropdown, he only sees his values. Projects of course can and will have multiple users. In addition to that, there should be some project-relevant documents to download but these permissions can be set up by roles and that would be the problem here. My question is, what would be the best approach here? From my thinking I would set up the projects as pages and define the values with fields. But how can I set up the users to assign them to projects? Maybe creating the users also as pages or is there another way? The users should also only see their own data and not the data from the other guys. So meaning that once the user is logged in he only sees his dashboard and a dropdown. I know this example sounds a bit abstract but it should only visualise what a common approach would be to this problem. Would love to hear your thoughts!
  10. Is it possible to create custom markers? I have around 20 markers and want to show them as numbered coloured dots on the map. Its basically just a red spot (all CSS, no images) with the number right in the middle. Not sure if this has already been asked here before. Anyone else tried this before?
  11. Thanks a lot for the heads up guys. I will check for these security issues right away. I simply was not aware of this. Cheers!
  12. Hi there, just a small update on this for those who are interested. Finally I've got my script / download proxy up and running. This is the code that generates a list with downloadable files (in this case logos) through a repeater field. <?php foreach($page->logos as $logo) { echo "<p><a href='{$config->urls->root}download.php?pageid={$logo->id}&file={$logo->logo_file}'>{$config->urls->root}download.php?pageid={$logo->id}&file={$logo->logo_file}</a></p>"; } ?> So a download links then looks like this: http://www.domain.com/download.php?pageid=1057&file=hi_res_100_percent_pure_logo.zip Here is the download.php: <?php // bootstrap PW include("./index.php"); // make sure user is logged in if(wire("user")->isLoggedin()){ $fn = wire('input')->get->file; $pid = wire('input')->get->pageid; $filepage = wire("config")->paths->files; // put together the complete path to the file $filename = $filepage.$pid.'/'.$fn; if(!$filename) die("download not found"); // send file to browser wireSendFile($filename, array('exit' => true)); } else { wire("session")->redirect("/"); } ?> Everything works great now. However I still wanted to protect the original path of the files (assets/files/...) allthough nobody would know the exact location. To do this I modified to the .htaccess to suite my needs to block all unwanted access to files with the most common endings for downloads (e.g. zip, rar, pdf, etc.) So the part in my .htaccess which takes care of that is the following: <FilesMatch "(^#.*#|\.(htaccess|htpasswd|ini|phps|bak|config|dist|fla|in[ci]|log|psd|pdf|zip|rar|sh|sql|sw[op])|~)$"> # Apache < 2.3 <IfModule !mod_authz_core.c> Order allow,deny Deny from all Satisfy All </IfModule> # Apache 2.3 <IfModule mod_authz_core.c> Require all denied </IfModule> </FilesMatch> I found that part during my research for .htaccess modifications and finally I ended up with using that part of the HTML5 Boilerplate. I know that might be a bit strict and I don't know yet if there are any issues with that but so far everything seems to work fine. Thanks to all the helpers (especially Horst) for guiding me that way to get my solution to work.
  13. now THAT is confusing Sorry for that - this was on my second installation on a laptop where I have a subdirectory under my localhost folder. So "return-pw" is the project folder where my PW installation is located. I placed the download.php file into the sites/templates directory. Maybe that is the problem? Does it belong into the document root of the website project ?
  14. Sorry what I wanted to say was that this page with the repeaters etc was working fine. The output of the fields and the structure. The only problem is still that download script is not working. I replaced the <a href ..> with the code that builds the download link that it looks like this now: <?php foreach($page->logos as $logo) { echo "<p><a href='{$config->urls->root}download.php?pageid={$logo->id}&file={$logo->logo_file}'>{$config->urls->root}download.php?pageid={$logo->id}&file={$logo->logo_file}</a></p>"; } ?> And the link is looking like this: /return-pw/download.php?pageid=1057&file=hi_res_100_percent_pure_logo.zip /return-pw/download.php?pageid=1058&file=hi_res_remote_area_logo.zip But its still not working. When I click on it I get redirected to my 404 page.
  15. Sorry when I missed to mention the repeaters earlier. I was not aware that these could have an important effect to the logic of the script. But anyway - you are right. $page->logos is a Repeater Field. It consists of an file field (logo_file) and an image field (logo_thumb). The result on the page looks something like this (see attachment) Everything works fine. In my template I use the following code to get this result: <ul class="blocks-5 dl-list"> <?php foreach($page->logos as $logo) { ?> <li> <a href="<?php echo $logo->logo_file->url; ?>" title="<?php echo $logo->logo_file->description; ?>"> <img src="<?php echo $logo->logo_thumb->url; ?>" title="<?php echo $logo->logo_thumb->description; ?>" alt="<?php echo $logo->logo_thumb->description; ?>"> <h3><?php echo $logo->logo_thumb->description; ?></h3> </a> </li> <?php } ?> </ul> When I use your foreach code I get a result something like this: /localhost/download.php?pageid=1057&file=hi_res_100_percent_pure_logo.zip /localhost/download.php?pageid=1058&file=hi_res_remote_area_logo.zip Thanks for your time! I really appreciate this!
×
×
  • Create New...