kongondo Posted June 21, 2021 Author Share Posted June 21, 2021 15 hours ago, Roych said: <h3><a href="<?=$pages->get((int) $dot->value->url);?>"><?= $dot->infoLabel;?></a></h3> There is no variable value in this module's API. The page id is at the variable info. So: <? php $pageReferencedByMarker = $pages->get((int) $dot->info); // do something with $pageReferencedByMarker 1 1 Link to comment Share on other sites More sharing options...
Roych Posted June 21, 2021 Share Posted June 21, 2021 38 minutes ago, kongondo said: There is no variable value in this module's API. The page id is at the variable info. So: <? php $pageReferencedByMarker = $pages->get((int) $dot->info); // do something with $pageReferencedByMarker I think I got it ? <?php $pageReferencedByMarker = $pages->get((int) $dot->info);?> <a href="<?=$pageReferencedByMarker->url?>"><h4><?= $dot->infoLabel;?></h4></a> <?php {};?> This works, thank you ? R Link to comment Share on other sites More sharing options...
Stefanowitsch Posted September 7, 2023 Share Posted September 7, 2023 I am in the need of using this module in a current project ? Turns out it works just as fine as I could ever wish! Except one thing: I want to make use of Repater Field Items as selectable pages only. So I added this line of code in the field settings. The page ID in this case is my repeater field that contains the child elements (=pages) that I want to be able to select. This works but unfortunately I see only the page IDs in the AsmSelect Inputfield as labels: I know that there is a setting for the AsmSelect to tell which field to use for the label: BUT since the AsmSelect in the ImageMarker module is generated via API code it is not possible to adjust this setting. @kongondo can you help me out on this one? it is somehow possible to tell the AsmSelect which field to use as a label? Link to comment Share on other sites More sharing options...
bernhard Posted September 9, 2023 Share Posted September 9, 2023 I guess the module uses something like $page->get('title|id') for the labels and since your page has no title field it falls back to the id. You can easily overwrite the "title" property of your page via hook! In this example I overwrite it for the "repeater_rpb_textgrid_items" template and set it to display the field "rpb_textgrid_headline" instead of "title": <?php $wire->addHookProperty("Page(template=repeater_rpb_textgrid_items)::title", function ($event) { $event->return = $event->object->rpb_textgrid_headline; }); Link to comment Share on other sites More sharing options...
Stefanowitsch Posted September 11, 2023 Share Posted September 11, 2023 On 9/9/2023 at 10:39 AM, bernhard said: I guess the module uses something like $page->get('title|id') for the labels and since your page has no title field it falls back to the id. You can easily overwrite the "title" property of your page via hook! In this example I overwrite it for the "repeater_rpb_textgrid_items" template and set it to display the field "rpb_textgrid_headline" instead of "title": <?php $wire->addHookProperty("Page(template=repeater_rpb_textgrid_items)::title", function ($event) { $event->return = $event->object->rpb_textgrid_headline; }); That's an interesting approach. The repeater items are located here in this case (rep_stories), how would I hook into the title rendering function in this case? Link to comment Share on other sites More sharing options...
bernhard Posted September 11, 2023 Share Posted September 11, 2023 Link to comment Share on other sites More sharing options...
Stefanowitsch Posted September 11, 2023 Share Posted September 11, 2023 2 hours ago, bernhard said: Ah sorry, my bad! This is not what I meant. I want to make the headline field of the repeater item pages shown in my screenshot to be listed in the AsmSelect Inputfield of the Image Marker Field. Right now this AsmSelect Field is only showing the page ID's of the repeater item pages: I don't know if this is even possible via hook. Link to comment Share on other sites More sharing options...
bernhard Posted September 11, 2023 Share Posted September 11, 2023 Ah, sorry - that's what I already showed in my previous post! Just find out the template of your repeater items and use the hook that I posted. Link to comment Share on other sites More sharing options...
Stefanowitsch Posted September 11, 2023 Share Posted September 11, 2023 I now changed Line 322 in InputfieldImageMarker.module from $addInfoPages = $modules->get('InputfieldAsmSelect'); foreach($opts as $opt) $addInfoPages->addOption($opt->id, $opt->title); to: $addInfoPages = $modules->get('InputfieldAsmSelect'); foreach($opts as $opt) $addInfoPages->addOption($opt->id, $opt->headline); Now the headline is shown as title in the select field: But the bummer is: It turns out that this field does not work properly inside a repeater matrix. The table with the marker coordinates never shows up after saving ? Link to comment Share on other sites More sharing options...
bernhard Posted September 11, 2023 Share Posted September 11, 2023 I thought that repeater pages have their own template, sorry. If that's not the case then just modify my hook to check the page's parents: Here the $page is a repeater item. You can inspect its parents like shown in line 1 and you can add something like shown in line 2 into your hook to only fire that hook that overrides the title if the parents have your repeater parent page. If not, then early exit of that hook. <?php $wire->addHookProperty("Page::title", function ($event) { $page = $event->object; if(!$page->parents->has("name=for-field-157") return; $event->return = $event->object->headline; }); 1 Link to comment Share on other sites More sharing options...
Crawford Tait Posted September 19, 2023 Share Posted September 19, 2023 I've inherited a site using this module and I'm seeing the integer rounding issue for marker positioning. I've read the other issues here and it looks like all the changes have been made in the code and database, AND I can see non-integer values in the database, but when I save any new ones they get rounded! Anyone have any ideas? Link to comment Share on other sites More sharing options...
Crawford Tait Posted September 20, 2023 Share Posted September 20, 2023 Finally found it, in getDatabaseSchema in FieldtypeImageMarker.module // our coordinates fields $schema['x'] = 'FLOAT NOT NULL DEFAULT 0'; $schema['y'] = 'FLOAT NOT NULL DEFAULT 0'; // indexes, for any fields that need to be searchable from selectors $schema['keys']['data'] = 'KEY data(data)'; //$schema['keys']['x'] = 'KEY x(x)'; //$schema['keys']['y'] = 'KEY y(y)'; Change x and y to FLOAT and I commented out their indexes since floats don't index well (i think) Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now