Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Currently if an element has the attribute frx:foreach="*" there's no way to ignore the id of this element. Forena will always assign this element an id.
For example:
<root_tag frx:skip_root="true" id="forena-1" frx:block="dpisql/ACESHeaderDelivery">
<Header frx:foreach="*" id="forena-2">
<blah>stuff</blah>
</Header>
</root>
Header must always have an id in this situation.
I propose we create a frx:skip_id element, that when set to true, the frx:foreach element does not need an id. There are some cases in XML that's being validated where you cannot have an id for these frx:foreach elements.
So in the below example, the generated report would not display an id for the Header tag because we've added frx:foreach="true":
<root_tag frx:skip_root="true" id="forena-1" frx:block="dpisql/ACESHeaderDelivery">
<Header frx:foreach="*" frx:skip_id="true" id="forena-2">
<blah>stuff</blah>
</Header>
</root>
Comment | File | Size | Author |
---|---|---|---|
#14 | forena-no-ids.patch | 3.22 KB | metzlerd |
#13 | file-frx-version.png | 180.35 KB | jamesdixon |
#13 | watchdog-has-forena-id-attr.png | 34.63 KB | jamesdixon |
#13 | wysiwyg-frx-version.png | 15.15 KB | jamesdixon |
#9 | no_forena_ids_2222743.patch | 1.3 KB | metzlerd |
Comments
Comment #1
jamesdixon CreditAttribution: jamesdixon commentedComment #2
jamesdixon CreditAttribution: jamesdixon commentedHere's a patch we used to do this on the 3.x branch.
Comment #3
jamesdixon CreditAttribution: jamesdixon commentedComment #5
metzlerd CreditAttribution: metzlerd commentedCommitted to 7.x-3.x-dev branch, but then began to wonder. The actual way to remove the attribute right now is to remove it from the source. It is true that forena adds ids to all elements that have frx attributes in order to give it a way to preserve the attrributes when a wysiwyg editor such as tinymce is used. Perhaps though it would be better to have the editor strip the forena-# tags off of the document before saving. In this fashion you could simply remove the ids from the .frx file an have the attributes not display. That is the way the current code would behave in both branches. That is if you manually remove the forena-1 id from this element, it will happily render without it and without this patch.
Does that make sense?
Comment #6
jamesdixon CreditAttribution: jamesdixon commentedYes that makes sense. Do you mean we should check for a frx:skip_id="true" on the element, and then if we are, do not create the id="forena-#" for that particular element?
Comment #7
jamesdixon CreditAttribution: jamesdixon commentedAlso, if we decide to go this route, which php file in forena is adding the id="forena-#"?
Thank you!
Comment #8
metzlerd CreditAttribution: metzlerd commentedNot quite what I meant. What I'm thinking is that normally you can just remove the attribute altogether for all elements prior to saving. That is, if they don't mean anything then there is no real reason to save them. So if you don't want an id on an element you just leave the Id off. It's true that when you use the forena provided UI for editing a report it will add them, in the off chance that you are using the wysiwyg editor, we need the ids to put the frx attributes are put put back on the elements (The wysiwyg editors will generally strip them off).
Comment #9
metzlerd CreditAttribution: metzlerd commentedHere's a patch for the 7.4.x version that illustrates what I'm talking about. I'm leaving the 7.x-3.x branch the way that it is, but his should deal with the need for 7.x-4.x in a more robust way. That is you can just remove the ids when you don't want them to be included.
Comment #10
jamesdixon CreditAttribution: jamesdixon commentedYeah definitely that's a more intuitive way of doing it. I wasn't sure if there was another reason outside of the WYSIWYG editor validation the ids were being saved when none were specified.
Comment #11
metzlerd CreditAttribution: metzlerd commentedGiven that this patch was committed to 7.x-4.x code tree (should be in as of beta2) going to call this one done.
Comment #12
jamesdixon CreditAttribution: jamesdixon commentedYes this works great thank you!
Comment #13
jamesdixon CreditAttribution: jamesdixon commentedActually my bad, I missed the ids being added even though they're not in the saved .frx file.
When I save the frx report from WYSIWYG, the id="forena-[num]" appears in the editor, but when I check the actual myreport.frx file there is no id.
Running the report, for some reason it is reading the WYSIWYG version of the frx, not what's in the frx file. I tried clearing cache and it happened again.
Throwing a watchdog before we check for the id attribute in renderers/FrxRenderer shows that the forena-[num] id attribute is being included.
I added some screenshots to show what's happening. The Footer element is rendering with an id:
It's 1 instead of forena-6 as I have the numeric ids skininfo setting set to true.
Is it possible the WYSIWYG version of the .frx is being cached somehow? The frx version of the file clearly has no id, but the id is being picked up at render time somehow.
Comment #14
metzlerd CreditAttribution: metzlerd commentedFor the record, here is a patch that solved this.
Comment #15
metzlerd CreditAttribution: metzlerd commentedThis patch was tested fixed, comitted and pushed.
Comment #16
jamesdixon CreditAttribution: jamesdixon commentedThanks I can confirm it worked!