Possible Field Type (Random Unique Number)
Permalink Browser Info Environment
I imagine this might be possible by using the PHP Field but I'm not a developer (just an aspiring one). Therefore I'm wondering a new type of field is possible.
My problem is I've created a block using static html fields for the most part which contains a bootstrap accordion. If I add more than one accordion block to a page the 2nd accordion doesn't work because the div and href identifiers need to have unique names in each accordion.
Therefore I'm wondering if a field could be created to provide a unique name/number in some way (perhaps from a database table) that could be used as the div id and the href address.
Hopefully this query makes sense.
My problem is I've created a block using static html fields for the most part which contains a bootstrap accordion. If I add more than one accordion block to a page the 2nd accordion doesn't work because the div and href identifiers need to have unique names in each accordion.
Therefore I'm wondering if a field could be created to provide a unique name/number in some way (perhaps from a database table) that could be used as the div id and the href address.
Hopefully this query makes sense.
Type: | Discussion |
---|---|
Status: | Resolved |
Hi Ramon
Very kind of you. The file is attached.
There's a couple of glitches with it at the moment when viewing the completed block whereby the link to the file doesn't seem to work and there's an error on editing the block due to the invalid date/time but these don't matter. I'm sure I'll sort them.
If the javascript required to make the block work is loaded in the block is causes problems on saving the page. Therefore I attach these files using a custom header to the page. I may look to include them in the theme instead. I also attach these files.
I also attached the css I load in the same header.
Many Thanks
Gordon
Very kind of you. The file is attached.
There's a couple of glitches with it at the moment when viewing the completed block whereby the link to the file doesn't seem to work and there's an error on editing the block due to the invalid date/time but these don't matter. I'm sure I'll sort them.
If the javascript required to make the block work is loaded in the block is causes problems on saving the page. Therefore I attach these files using a custom header to the page. I may look to include them in the theme instead. I also attach these files.
I also attached the css I load in the same header.
Many Thanks
Gordon
Hi Ramon
You'll also note that in the block there are inner accordions that also need unique identifiers. The divs and hrefs that need to be unique are as follows. I've attached the original html file that I created the block from.
From line 24 the div class and div id need to be unique so that any other blocks added to the page function properly and independently
From line 29 the href needs to be unique
From line 34 which needs to match the href on line 29
From line 43 the div class and id need to be unique so that any other blocks added to the page function properly and independently
From line 48 the data-parent needs to match the div id on line 43 and the href needs to be unique for the other nested accordions to act independently
and lastly on line 53 the div id needs to match the href on line 48
I very much appreciate it's potentially a tricky one! Or at least it is for me. Hopefully quite straightforward for you.
Thanks
Gordon
You'll also note that in the block there are inner accordions that also need unique identifiers. The divs and hrefs that need to be unique are as follows. I've attached the original html file that I created the block from.
From line 24 the div class and div id need to be unique so that any other blocks added to the page function properly and independently
<div class="panel-group" id="accordion">
From line 29 the href needs to be unique
href="#collapseOne">
From line 34 which needs to match the href on line 29
<div id="collapseOne" class="panel-collapse collapse">
From line 43 the div class and id need to be unique so that any other blocks added to the page function properly and independently
<div class="panel-group" id="nested">
From line 48 the data-parent needs to match the div id on line 43 and the href needs to be unique for the other nested accordions to act independently
<a data-toggle="collapse" data-parent="#nested" href="#nested-collapseTwo">
and lastly on line 53 the div id needs to match the href on line 48
<div id="nested-collapseTwo" class="panel-collapse collapse in">
I very much appreciate it's potentially a tricky one! Or at least it is for me. Hopefully quite straightforward for you.
Thanks
Gordon
Hi Gordon,
I've made some changes to your block myself. Let me know if this does the trick for you! Be sure to clear the cache if you have caching set to "On" for pages.
It's quite hard to make a field overcome everything you got in here, as you need multiple ID's and use them at multiple spots...
I have to go out the office, so if you have any questions, just ask. I will reply a bit later. I hope the view.php file is a bit more "structured" now, as I've indented a bit to make it look like it should.
Kind regards,
Ramon
I've made some changes to your block myself. Let me know if this does the trick for you! Be sure to clear the cache if you have caching set to "On" for pages.
It's quite hard to make a field overcome everything you got in here, as you need multiple ID's and use them at multiple spots...
I have to go out the office, so if you have any questions, just ask. I will reply a bit later. I hope the view.php file is a bit more "structured" now, as I've indented a bit to make it look like it should.
Kind regards,
Ramon
Ramon that is brilliant. I can't thank you enough.
There is still a small problem though which is that the file link doesn't work. It just links to a blank url in the view block.
I was going to investigate this once the more perplexing issue was resolved but I assume the block can't be brought back into the Block Designer to make changes?
Really great work though. Thankyou again.
There is still a small problem though which is that the file link doesn't work. It just links to a blank url in the view block.
I was going to investigate this once the more perplexing issue was resolved but I assume the block can't be brought back into the Block Designer to make changes?
Really great work though. Thankyou again.
Hi Gordon,
Does the file save though, if you go back into the Block's edit form? I see a correct anchor on my view though... It's using the relative path of a file ("getRelativePath" on the file object). If I leave the file empty, it's just not showing an anchor at all. So not sure what's going on here. Can you make screenshots of what you do and what the HTML is perhaps? Or a video. Something so I can see what's inputted, ouputted and done in what way.
Perhaps refresh the block type? Follow the instructions from this page:
https://www.concrete5.org/marketplace/addons/block-designer/question...
Let me know when you have more info for me! :)
Kind regards,
Ramon
Does the file save though, if you go back into the Block's edit form? I see a correct anchor on my view though... It's using the relative path of a file ("getRelativePath" on the file object). If I leave the file empty, it's just not showing an anchor at all. So not sure what's going on here. Can you make screenshots of what you do and what the HTML is perhaps? Or a video. Something so I can see what's inputted, ouputted and done in what way.
Perhaps refresh the block type? Follow the instructions from this page:
https://www.concrete5.org/marketplace/addons/block-designer/question...
Let me know when you have more info for me! :)
Kind regards,
Ramon
Hi Ramon
It definitely saves the file link. It just the view html returns a blank target.
My intention in the Block Designer was to uncheck the "open in new tab" option as I thought that may be causing the issue and I could do without that instead leaving it to the user to select how to open the file.
The screenshots of the view and edit are attached.
It definitely saves the file link. It just the view html returns a blank target.
<a href="" target="_blank"> WGLogoRectangleTransparentWhite300w.png </a>
My intention in the Block Designer was to uncheck the "open in new tab" option as I thought that may be causing the issue and I could do without that instead leaving it to the user to select how to open the file.
The screenshots of the view and edit are attached.
Also, the block refresh didn't have any affect I'm afraid.
And what if you replace the controller.php file with the attached one?
Sorted!
Can't thank you enough.
Hopefully my ignorance has given some ideas for future field additions.
Great work.
Gordon
Can't thank you enough.
Hopefully my ignorance has given some ideas for future field additions.
Great work.
Gordon
Good explanation, at first I didn't know what you wanted it for, but with this usecase, it makes sense. Are you able to send me the config.json file of your Block? It should be generated under /application/blocks/your_block_handle. With this, I can take a look if I can implement something to keep you going. I will also take a look of course for the possibilities of a new field type.
Let me know!
Kind regards,
Ramon