Xonox
Members-
Posts
95 -
Joined
-
Last visited
Everything posted by Xonox
-
Hi, I have a template that it's working fine in development, however I can't get it to work on production! It shows every information inside repeater fields except the images. Here's the template: These are the circuit_day_image settings: This is the code: <?php foreach($page->circuit_days as $circuit_day) { if($circuit_day->circuit_day_image) { $day_image = $circuit_day->circuit_day_image->size(300, 300)->url; echo '<img src="' . $day_image . '" />'; } else { echo 'No image! :('; } echo '<h2>' . $circuit_day->title . '</h2>'; echo $circuit_day->body; } ?> I always get "No image! :(" I think I'm doing everything right! Anyone else with a similar problem? Update After uploading the production database into my server, the images stopped working. It can be one of two problems: 1. Bad field configuration; 2. Something wrong with the Database. I can't find the problem. Any suggestion is welcome, thanks, Update 2 I forgot to upload the images. It's working on dev and not on production. Still no clue! Clue 1 When I insert <pre><?php print_r($circuit_day); ?></pre> On development I get a clean list for each repetition: However, on production, the command gets on a weird recursive loop that takes forever (it even slows the browser to a halt): What might be going on?
-
MySQL number of processes causes the site to stall
Xonox replied to Xonox's topic in General Support
Thanks for your suggestion. I've made the change to InnoDB. All I can do now is wait, to see if it solved. This problem is so inconsistent, that I don't know what to do to test it. As far as I know, there's no dump process. You think it might be caused by some kind of auto backup process in the server? Thank you for your help. -
Hi, I'm having a problem with one of my sites, something that doesn't happen with any other of my PW implementations. The site stalls due to the number of processes that reaches the server limit (Max. set to 40). It looks like some MySQL requests remain active, without closing. There's no particular event that I can connect to it - like an increase of traffic or whatever - which make it even more difficult to know what might be causing it. It's not a recurrent problem, but sometimes it happens. It might be once a month, once a week or once every three months and its virtually impossible to replicate in my local server. Here's what our server managers sent to me to help sort out the problem: When I run the query in the database it runs without problems SELECT id, templates_id FROM pages WHERE id IN(1,2,28,29,30,37,38,40) Returns: Showing rows 0 - 7 (8 total, Query took 0.0003 seconds.) The pages that this query return are: 1 - 2 - admin 28 - access 29 - users 30 - roles 37 - guest 38 - superuser 40 - guest Looks like some kind of problem with the admin section? Has anyone ever faced a similar problem? Might it be a server problem? A bug? I'm thinking on changing the site to another server, to see if it is a server problem. Thanks.
-
@BitPoet and @wbmnfktr, this might be EXACTLY what I'm looking for. I'll take a look. Thanks! I see that this a Core module, but not installed when we first install ProcessWire, I didn't remember to look there. I already used PW on about 20 projects, and for every challenge I've came across there's always a simple answer that this forum provides. Thanks.
-
Yes, I'm trying to solve a backend/administration problem. That would be an ideal solution. The client usually knows the books that he wants to add to a catalog by title, author or even SKU. Is there any autocomplete reference module? No. There's not anything about the books that can be used for automation. It might be an option, but not a very elegant one, in my opinion. This might be a good solution. The user can use the administration search box to select the books and add them to the catalog and then, edit the catalog to to sort the books and make the final adjustments. I'll check out these modules. Thanks @wbmnfktr
-
Not really what I'm looking for. I'm trying to solve an Admin side usability problem.
-
Hi, I would like your opinion about the best way to handle the following problem: I have a project that has thousands of books and with this books I can build catalogs with 10 to 20 books. My approach was to build a "catalog" template in which I can select the books and sort them out with a "Page List Select Multiple". Of course this is a problem when you have thousands of books. So I have two questions: 1. Is it possible to have a search page selector that allows me to define in which fields I can search (title, body, etc.)? If anyone knows of such a module please point it out. With so many books, for the user, is much easier to start typing a book name to filter the results, instead of scrolling through thousands of lines. 2. In your opinion would it be best to handle this problem from the book side? Selecting, inside each book, in which catalog it is present (I have much less catalogues than books). How would I handle the book sorting, then? As we all know, with ProcessWire there's more than one way to achieve the results, if anyone had this kind of challenge I would like to know how you handle it. Thanks.
-
Hi @tpr, Wonderful, elegant solution. I need this for my current project but I don't understand how I can get it. Have you made a module? Is it available? Thanks!
-
Can I add information to the images displayed inside the body?
Xonox replied to Xonox's topic in API & Templates
I tried Image Interceptor, and it didn't fit my needs. I guess I'm stuck with regex, then. I knew this, the problem is getting the original size and insert it in the body where the images are placed. I'll have to do it via regex/string replacement. Thanks for your help. I'll see what I can do with your input. -
Hi, I need to add the original image dimensions (width x height) for the images inserted in the body field, in a few data-fields. Something like: <a href="/site/assets/files/1092/image-1.jpg"> <img alt="" src="/site/assets/files/1092/image-1.690x0-is.jpg" width="690" data-width="1500" data-height="1000 "> </a> Where data-width and data-height are the image-1.jpg dimensions. I tried to do this through a file, to control the field output: templates/fields/post/body.php But turns out the body comes already formatted from the DB, so I can't override the image display, unless I use some cumbersome str_replaces. Even with this solution, it's impossible to achieve the desired result. Is there any way I can do this through a ProcessWire process? I know it can be done through php, reading the file's header to extract the height and width and then do a str_replace on the body string to insert the desired code. However I'm curious if it can be done in any simpler and more effective way, without having to read the files from disk and do the replaces. Thanks,
-
Saving page title via API fails for user creating more than one page
Xonox replied to Xonox's topic in API & Templates
Thanks I just added that to my code. Turns out the user name ($page->title) was hiding on a different language. So I guess I'll be using this to make sure it is stored on the default language: $p->title->setLanguageValue('default', $form['name']); However, is it possible for PW to automatically jump to new language? -
Saving page title via API fails for user creating more than one page
Xonox replied to Xonox's topic in API & Templates
WAIT!!!! I've got news. After cheking out the reservations closely, I found out that the title is being stored, hidden away on a different language from the default. So it's saved on the right field, but on the wrong language. How come? -
Saving page title via API fails for user creating more than one page
Xonox replied to Xonox's topic in API & Templates
I am not using current user or saving any kind of session whatsoever. About the structure, you nailed it. The user gave the same email for the two reservations. If Rick did both the reservations, he inserted the same email, because he doesn't know Xonox' email. So Rick did indeed receive both emails. The variable $form['name'] has the name, or else it wouldn't show up on the sent email. Every other information is saved, just not the $page->title. What does this do? -
Saving page title via API fails for user creating more than one page
Xonox replied to Xonox's topic in API & Templates
Ok, let me see if I can shed some light into this. 1. The user name (Rick, for instance), is saved into the "title" field ($page->title); 2. The page name is a microtime to make sure that it is unique ($page->name = microtime()); 3. As for the page_target, it's a hidden field in the form to make sure that the user reservation (Rick) is associated to the right event (Get a Cup of Coffee). Now the problem of not storing the value in the $page-title, only usually happens when the user (Rick) tries to add a friend (Xonox) to the same event (Get a Cup of Coffee) by filling the same form again with his email and phone number. The strangest thing is that neither Rick's or Xonox' name are added to the reservation. However, when Rick gets the two emails, both names are correct. -
Hi, I have a site that has events where the users can make a reservation and something really weird is happening. This is the code: $form = array( 'name' => $sanitizer->text($input->post->name), 'email' => $sanitizer->email($input->post->email), 'phone' => $phone, ); $p = new Page(); $p->template = 'reservation'; $p->parent = wire('pages')->get('/agenda/' . $sanitizer->text($input->post->page_target) . '/'); $p->name = microtime(); $p->title = $form['name']; $p->save(); // CODE TO SEND EMAIL BELOW The user path is: 1. User fills the form with name, email, phone and some more information. 2. Form is validated to see if every information is ok. 3. Information is saved into a new page (reservation template). 4. Send email to user. Everything works fine except in one case: When the same user fills the same form more than once (to add reserves for one or more friends), usually using the same number and email, the friend's name is not filled in the "title" field. This seems to be the only field that fails, it shows empty on the backoffice. However, the email sent to the user has the name (using the same $form['name'] variable). Am I missing something?
-
I eventually change the whole system: 1. Created a template "private_gallery" that has two fields: "login" and "password" (Text). 2. When accessing the private gallery the system checks if user is logged in via cookie. If it is not logged in it shows the login page. The galleries are created by the site master, so I don't think there's a need for the usual security involved on a common password. And I can secure the images for each gallery. Thanks for your help.
-
Even if I give the user profile-edit permissions, the gallery images are still not available on the site - even if I give the client profile permissions to view the fields. This leads me to think that creating the private_gallery inside the user profile wasn't the best option, despite being very practical. The link I posted first, had some reference to a module that @ryan developed. But that module link isn't working and I can't find anything of that kind in the Modules section. So what's the best approach? Creating a user and a specific gallery page with that user name so that I can validate, as suggested by @onjegolders? if ($user->name === $page->name) { // show all the pictures and other member stuff } else { throw new Wire404Exception(); }
-
I've tried $config->pagefileSecurePathPrefix = '-'; I get the same results. Can't load the images inside the template. $config->pagefileSecurePathPrefix = 'sec'; I get the same results. Can't load the images inside the template but they're not secure on hotlinking.
-
Just to make my question clearer, this is the code on the private gallery page: if(!$user->isLoggedin() && count($user->private_gallery)) { ?> <div id="gallery"> <?php foreach($user->private_gallery as $image) { $thumbnail = $image->size(400, 0); echo '<a href="' . $image->url . '"><img src="' . $thumbnail->url . '" /></a>'; } ?> </div> <?php } Shouldn't the user, that it's logged in, have access to the images inside his user?
-
Thanks... I added this to my config: $config->pagefileSecure = true; $config->pagefileSecurePathPrefix = '.'; This secured the images, however, the gallery stopped working (no images whatsoever). I believe that the reason is this: 1. I have a page with a template called "private_gallery" that can only be viewed by users with the profile "client". 2. However, the client "gallery" is associated to the "user" template, so it's not related to the page in any way. So I'm trying to get to the user gallery, through a different page. How can I do this? Am I missing something? With $image->url, I'm getting the images URL without the "." that secures the folder.
-
Hi, I'm building a site that has private galleries, according to the input of this topic: The topic is a couple of years old but was enough to get me going. Here's the method I chose: 1. Created an image field called private_gallery; 2. Associated this field to the ProcessWire user template, this way you create a user with password and gallery very easily; 3. Created a gallery template that checks for the user login and displays their gallery. So, what do I need? Everything is working fine, but if I copy the image link and paste it on a non logged in browser, I can see the image. What's the best method to prevent non logged in users from viewing these images?
-
I've been using PW for quite a while, now, so I would like to give back to the community that helped me so many times. I had this customer that wanted to use the Google Translate API to automatically translate the site, so I built this function that takes advantage of it without the need to use the API on every page cycle. I put it on a file that gets called on the _init.php, so that I can use it on every template. Here it is: <?php function googleAutoTranslate($page, $field) { // Turn off outputFormatting $page->of(false); // Get current language and field content for this language $current_language = wire('user')->language->name; $field_content = $page->getLanguageValue($current_language, $field); // Is there any content for this language? if($field_content != '') { // Do nothing! } else { // No content, lets translate... // Get default language text $text = $page->getLanguageValue('default', $field); // Translate only if there's content in the default language if($text != '') { // Translate it $apiKey = 'YOUR API KEY HERE'; $default_language = 'pt'; // Your default language here! $url = 'https://www.googleapis.com/language/translate/v2?key=' . $apiKey .'&q=' . rawurlencode($text) . '&source=' . $default_language . '&target=' . $current_language; $json = json_decode(file_get_contents($url)); $field_content = $json->data->translations[0]->translatedText; // Save translated text $page->$field->setLanguageValue($current_language, $field_content); $page->save(); } } // Turn on outputFormatting $page->of(true); // Return result return $field_content; } ?> Whenever you use a field on a template that should be auto translated, just call the function with a page object and the field name, like so: echo googleAutoTranslate($page, 'body'); Features: Translation occurs only once per field, so you don't need to keep paying translations (it stores the translation into the field language); You can correct the translation in the admin area and it won't be overwritten; If you need the translation to be made again, just delete the field content in the needed language. For the translation to occur, content must exist in the default language. I had to fight a little to get this working, so I hope this helps anyone, who comes across this particular need. Nice Things To Have If someone wants to give it a shot to make this into a module, please do. It would be nice to have a checkbox "Enable Google auto translate for this field", when you edit a field input features. Don't Spend Too Much Mind you that the Google translate is a payed service! and needs a Credit Card to get it going (even with $300 free credit); With a relatively small site (and the tests made to get this to work) I already spent about 80.000 translated characters = $3, Hope this helps someone!
-
Developing, I must keep deleting the assets/cache/FileCompiler folder
Xonox replied to Xonox's topic in General Support
I also develop like that. I noticed that when I copy the changes to the production server, there's no need to delete the cache. So I'm figuring that it must be some configuration. I haven't had the time to compare both dev and the production servers. If I get to any conclusion, I'll post it. -
Developing, I must keep deleting the assets/cache/FileCompiler folder
Xonox replied to Xonox's topic in General Support
When I do that, I get a Fatal Error. Can't use: $pages = wire('pages'); Fatal error: Call to undefined function wire() -
Developing, I must keep deleting the assets/cache/FileCompiler folder
Xonox replied to Xonox's topic in General Support
The changed file doesn't appear as compiled in the logs. After I delete the FileCompiler folder, the template is updated, but the file still doesn't show as compiled in the logs. However, the file is inside the FileCompiler folder. If the file is in the folder, shouldn't it show in the logs?