Jump to content

efiguerola

Members
  • Posts

    14
  • Joined

  • Last visited

Recent Profile Visitors

1,309 profile views

efiguerola's Achievements

Jr. Member

Jr. Member (3/6)

0

Reputation

1

Community Answers

  1. Hello @horst, First of all, thank you for adapting CroppableImage for ProcessWire 3.x. Modules like this one make ProcessWire into an (even more) robust and flexible option for all kinds of new projects. I downloaded CroppableImage3 and I was wondering if "free" (variable) width/height is a supported feature in this module (and if not, could it be, pretty please?) For example, suppose I have this in my field's crop settings: freeheightcrop,900,0 This would allow the user to create a crop of 900px width and a custom height, so maybe the first image ends up being 900x500, the second one is 900x320, etc. It all depends on the dimensions of the area the user has selected during crop generation. The calculation would be as follows: get the aspect ratio from the area selected by the user (e.g. a 640x360 area would have a 16:9 aspect ratio). Then, we already know the final width (900px). We calculate the final height using the selected area dimensions and the known final value (i.e. 900 * 360 / 640 = 506.25px --> round down --> 506px final height). Same idea for width: freewidthcrop,0,900 only this time the width is the variable. I tried to put freeheightcrop,900,0 into the field configuration and ProcessWire accepted it, but the user's crop won't be saved (it generates a crop that is exactly the same as the original image). Also, when cropping, the upper text that indicates the size of the selection will display "NaNxNaN" until the user selects an area.
  2. @kixe Hi, I gave you the Chrome error code just because it is the one I personally use, but I get the same kind of behavior in other browsers as well, it is not a browser thing. I didn't get to make any settings because the error happens immediately after creation of the field.
  3. Hello @kixe I have installed your module (latest version) on ProcessWire 3.0.36. However, when I create a new field using the FieldtypeSelectExtOption, ProcessWire tries to load the field edition page for the new field (e.g. http://www.mydomain.com/cms/setup/field/edit?id=111), but fails to do so a few seconds of waiting. In Google Chrome I get "ERR_CONNECTION_RESET". I'm not seeing any error(s) (regarding this) logged in ProcessWire's error log and I have $config->debug set to true. I should clarify that the script is not reaching max_execution_time. Apparently what happens is that, somehow, the connection with the page is reset. This is the first time a ProcessWire module behaves this way for me. Do you have any ideas as to what may be happening?
  4. Hi again, I noticed there are no replies. Maybe other people can't reproduce this bug?
  5. Hello! We are currently using ProcessWire 2.7.2 for one of our sites and we're having a bit of a problem with an Image field. The field is configured to display images using the "Rows" view, display thumbnails in page editor and it has a maximum of 1 allowed file. However, when the field is rendered within a Repeater item, it defaults to the "Grid" view, completely ignoring that I had selected the "Rows" view while configuring the field. I feel that this is bad UX for the user, because if he/she wants to use the little trash can icon to delete the uploaded image, the user *needs* to know that he/she has to click the View Toggle icon first, in order to get to the "Rows" view. I want "Rows" view to be the default, so the user immediately sees the trash can icon once an image is uploaded. What do you think?
  6. Thanks, that worked! I didn't know about "rel", where can I find documentation on that feature?
  7. I have the following selector: wire("pages")->find("template=news|video, parent|secondary_categories=$page, limit=8, sort=-publish_date, sort=title"); parent represents the parent of the current page $page is the object representing the current page secondary_categories is a field assigned to the "news" and "video" templates, it is of type "Page" and it uses ASMSelect for selecting multiple pages So basically, what I'm telling ProcessWire is: "Get me 8 pages that use either the 'news' OR 'video' template, AND that also have the current $page as their parent OR that have a reference to the current $page within their secondary_categories field". The problematic part is: parent|secondary_categories=$page The OR operator is not working - I'm only getting pages where the parent is $page, and none where $page is in secondary_categories.
  8. ----------------------------------------------------------------------------------- [WARNING] This is a long post. Sorry about that. ----------------------------------------------------------------------------------- I solved this, so might as well post the details here. There *is* some weird ProcessWire behavior going on, but first things first. 1. I didn't create the repeater field correctly (oops). As a part of the installation process for my module, I had to programmatically create a template which had a repeater as one of its fields. Now, I had a hard time finding documentation on how to do this exactly, and eventually I found a forum post that kinda helped me (here), but it would seem like it was missing some key steps needed in order to properly create a repeater field programmatically (perhaps due to it being an old post). I learned about those extra steps in another forum post (specifically, this one). 2. The repeater field table was receiving duplicate values for the ID of the first repeater item (a bug, perhaps?) So I fix the installation code, do a clean PW install, then install my module again. Everything works, beautiful. Except... I was checking out the table PW created for my repeater field, and I noticed something weird going on. Initially, I create a page using the template that has this repeater field. A new row is created on the repeater field table in the database. At this point there are no existing repeater items added to the repeater, so the row looks like this: The "data" column stores a comma-separated list of the IDs of every single repeater item owned by the repeater. The "count" column stores the amount of repeater items that the repeater owns. At this point, zero. However, when I added some items to the repeater using the interface I built for my module (a form receives the user input and stores it using the API, as per the Repeaters documentation), the ID of the first repeater item (and only the first one) appeared twice on the "data" column of the repeater field table. This also meant the "count" column had a value of [real amount of items + 1]. So, for example: In order to solve this issue, I had to do something in my code that I think shouldn't be necessary, but I needed it to work well, so... Regarding the code that saves the repeater/repeater items, I had to change it from this: public function processForm() { // Get the data sent with the form and sanitize it before using it. /*-OMMITED FOR BREVITY-*/ // Channel ID validations. /*-OMMITED FOR BREVITY-*/ // Get the channel object (a page). /*-OMMITED FOR BREVITY-*/ // TV Grid data validations. /*-OMMITED FOR BREVITY-*/ // We need to clean this channel's grid before working with it. /* channel = Page tvChannelGrid = Repeater field tvChannelGridShow, tvChannelGridShowDay, tvChannelGridShowDuration, tvChannelGridShowRow = Repeater fields */ if(count($channel->tvChannelGrid) > 0) { $channel->tvChannelGrid->removeAll(); // Remove all repeater items. $channel->save("tvChannelGrid"); // Save the repeater. $channel->save(); // Save the page. } // Add the grid items received from the module's form to the channel's grid. foreach($tvGridData as $i => $item) { $showId = intval($item["tv_show_id"]); $duration = intval($item["duration"]); $day = intval($item["col"]); $row = intval($item["row"]); // Create a new item and add it to the repeater. $gridItem = $channel->tvChannelGrid->getNew(); // New repeater item // Assign values to repeater item fields. $gridItem->tvChannelGridShow = wire("pages")->get($showId); $gridItem->tvChannelGridShowDuration = $duration; $gridItem->tvChannelGridShowDay = $day; $gridItem->tvChannelGridShowRow = $row; $gridItem->save(); // Save the newly built repeater item. $gridItem->of(false); // Recommended in a forum post while trying to solve the issue. $channel->tvChannelGrid->add($gridItem); // Add repeater item to repeater. } if(count($tvGridData) > 0) { // We clearly received some new items, so let's save our work. $channel->save("tvChannelGrid"); // Save the repeater. $channel->save(); // Save the page. } return "<h2>TV Grid processed.</h2><p><a href='" . $this->page->url . "?channelId=$channelId'>Go back to the TV Grid Editor.</a></p>"; } ...to this: public function processForm() { // Get the data sent with the form and sanitize it before using it. /*-OMMITED FOR BREVITY-*/ // Channel ID validations. /*-OMMITED FOR BREVITY-*/ // Get the channel object (a page). /*-OMMITED FOR BREVITY-*/ // TV Grid data validations. /*-OMMITED FOR BREVITY-*/ // We need to clean this channel's grid before working with it. /* channel = Page tvChannelGrid = Repeater field tvChannelGridShow, tvChannelGridShowDay, tvChannelGridShowDuration, tvChannelGridShowRow = Repeater fields */ if(count($channel->tvChannelGrid) > 0) { $channel->tvChannelGrid->removeAll(); // Remove all repeater items. $channel->save("tvChannelGrid"); // Save the repeater. $channel->save(); // Save the page. } // Add the grid items received from the module's form to the channel's grid. foreach($tvGridData as $i => $item) { $showId = intval($item["tv_show_id"]); $duration = intval($item["duration"]); $day = intval($item["col"]); $row = intval($item["row"]); // Create a new item and add it to the repeater. // FOR SOME REASON (), creating a variable here, storing the new grid item // inside said variable, and then passing the variable to the repeater's "add" // function as a parameter, causes the first repeater item's ID to be duplicated // in the repeater field's table (repeater field row, "data" column; also, wrong // repeater item count in "count" column). $channel->tvChannelGrid->add($this->createGridItem(array( "showId" => $showId, "duration" => $duration, "day" => $day, "row" => $row, ), $channel->tvChannelGrid)); } if(count($tvGridData) > 0) { $channel->save("tvChannelGrid"); // Save the repeater. $channel->save(); // Save the page. } return "<h2>TV Grid processed.</h2><p><a href='" . $this->page->url . "?channelId=$channelId'>Go back to the TV Grid Editor.</a></p>"; } function createGridItem($data, $grid) { $gridItem = $grid->getNew(); $gridItem->tvChannelGridShow = wire("pages")->get($data["showId"]); $gridItem->tvChannelGridShowDuration = $data["duration"]; $gridItem->tvChannelGridShowDay = $data["day"]; $gridItem->tvChannelGridShowRow = $data["row"]; $gridItem->save(); // Save the newly built item. $gridItem->of(false); return $gridItem; } At first I thought: "Okay, the problem seems to be that I need to isolate the piece of code that creates the new repeater item inside a separate function", but then I realized that's not quite it. That is because, even if I isolated that piece of code inside a different function, the problem still occurred if I created a variable ($gridItem) inside the foreach loop that stored the output of the createGridItem function. In the end, I had to pass the output of the createGridItem function directly to the repeater's add function, without storing it inside a variable first. Hmm, so I guess there is a tl;dr: (*) We need rich, readily available documentation for backend development / module development / doing things with code and not via GUI, in the same way we have awesome documentation for the frontend (pages, templates, API usage) aspect of PW. I think forum posts are great for solving specific issues, or maybe expanding on lesser known aspects of something, but they shouldn't be the primary source of information, there should be documentation pages for that. (**) Apparently, I cannot have a variable that stores a new repeater item inside a foreach loop, or PW does weird stuff. (*) Do note that I am not in any way demanding this happens, I'm merely making a suggestion. (**) If you notice I did some dumb mistake, point it out... I don't think so, but just in case... hahahaha.
  9. Here, this is from the database: MS Paint is the best, haha. Such a weird issue, though.
  10. Sadly this doesn't solve the problem. Any other ideas?
  11. Hello, I am developing a module that lets a user create, modify and save a "TV Grid" (the schedule for a TV channel). Here you can view some images that illustrate the concept: https://www.google.com/search?q=tv+grid&tbm=isch Of course, those are just examples and do not represent my specific implementation, but with that I hope you get the idea. The module installs a template for a "channel" (among other things). The "channel" has a "Repeater" field, where I store the complete grid for that channel. The repeater (grid) contains repeater items (grid items) that represent a scheduled show, e.g. ["Friends", Monday, 1st show of the day, lasts 60 minutes]. The repeater field is hidden from the user if he/she tries to edit the channel page via the admin's page edition interface. The intended way to edit this TV grid is by using the module's page that I've developed, which provides a custom interface for creating, manipulating and saving the grid. This of course means that I'm doing many things programmatically. The problem is that the repeater items I'm creating via code using the user's input just WON'T save. I've made all the code changes I could think of, trying different stuff, without positive results. Looking at the database, I notice the following when I run my code: - The corresponding row for the repeater field in its table is updated/saved. - However, no new rows are created for the repeater item fields (e.g. TV Show, duration, day, etc.). Would you please help me out here? I'm becoming insane ... I've included some code below. /* * More code before this, ommited because it isn't relevant. */ // Get the channel object (a Page). $channel = wire("pages")->get($channelId); if(!$channel->id) { $this->error("Channel does not exist. Grid can't be processed."); return ""; } // We need to clean this channel's grid before working with it. // "channel" is the Page // "tvChannelGrid" is the Repeater $channel->tvChannelGrid->removeAll(); $channel->tvChannelGrid->save(); $channel->save(); // Save the page.*/ // Add the grid items received from the module's form to the channel's grid. foreach($tvGridData as $i => $item) { // "tvGridData" is an associative array with data received from a form. $showId = intval($item["tv_show_id"]); $duration = intval($item["duration"]); $day = intval($item["col"]); $row = intval($item["row"]); $gridItem = $channel->tvChannelGrid->getNew(); // this must be done according to the documentation. $gridItem->save(); // Save the newly built item. // Assign values to repeater fields. $gridItem->tvChannelGridShow = wire("pages")->get($showId); // FieldtypePage $gridItem->tvChannelGridShowDuration = $duration; // FieldtypeInteger $gridItem->tvChannelGridShowDay = $day; // FieldtypeInteger $gridItem->tvChannelGridShowRow = $row; // FieldtypeInteger $gridItem->save(); // Save the newly built item. $channel->tvChannelGrid->add($gridItem); // Add the new item to the repeater. } $channel->tvChannelGrid->save(); // Save the repeater. $channel->save(); // Save the page.
  12. Uhm, my issue is not with the frontend side of things, but with the backend. The backend let's you choose from a selection of font-awesome icons for use as field icons, template icons, etc. I need to update that so the latest icons added to the font-awesome project are available to me for backend use. Said icons are stored in /wire/templates-admin/styles/font-awesome and I suspect they're somehow (code-wise) integrated to the core. To make things more clear, I've attached a screenshot.
  13. Hello, I'm new to ProcessWire (liking it so far ) and I was wondering: how can I update the collection of font-awesome icons used by ProcessWire, in such a way that the updated icon set is fully integrated with ProcessWire? I'm guessing there's more to it than simply overwriting the font-awesome folder... I want to update because I'd like to use a specific icon that is not included with the version of font-awesome icons that ProcessWire currently comes with.
×
×
  • Create New...