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.

Type: Discussion
Status: Resolved
gordoncWG
View Replies:
ramonleenders replied on at Permalink Reply
ramonleenders
Hi 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
gordoncWG replied on at Permalink Reply 1 Attachment
gordoncWG
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
gordoncWG replied on at Permalink Reply 1 Attachment
gordoncWG
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

<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
ramonleenders replied on at Permalink Reply 1 Attachment
ramonleenders
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
gordoncWG replied on at Permalink Reply
gordoncWG
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.
ramonleenders replied on at Permalink Reply
ramonleenders
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
gordoncWG replied on at Permalink Reply 2 Attachments
gordoncWG
Hi Ramon

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.
gordoncWG replied on at Permalink Reply
gordoncWG
Also, the block refresh didn't have any affect I'm afraid.
ramonleenders replied on at Permalink Reply 1 Attachment
ramonleenders
And what if you replace the controller.php file with the attached one?
gordoncWG replied on at Permalink Reply
gordoncWG
Sorted!

Can't thank you enough.

Hopefully my ignorance has given some ideas for future field additions.

Great work.

Gordon

concrete5 Environment Information

# concrete5 Version
Core Version - 5.7.5.6
Version Installed - 5.7.5.6
Database Version - 20151221000000

# concrete5 Packages
Block Designer (2.1.0), Block Designer Pro (2.1.0), Breadcrumb Trail Page Links (1.1), Document Library (0.9.4), Event Calendar (3.3.6), Handyman (1.0.8), HTML+PHP Code Block (1.0.1), Quick Tabs (1.0), Responsive Embed (1.0.1), S3 Storage (2.0.2), Spacer (0.9.3), Supermint Theme (3.3.1.3), Vivid Carousel (1.0.1), Vivid Simple Accordion (1.0.1).

# concrete5 Overrides
blocks/mailto/db.xml, blocks/mailto/css_form/repeatable-ft.form.css, blocks/mailto/css_form, blocks/mailto/edit.php, blocks/mailto/config.json, blocks/mailto/icon.png, blocks/mailto/add.php, blocks/mailto/view.php, blocks/mailto/auto.js, blocks/mailto/form.php, blocks/mailto/js_form/handlebars-helpers.js, blocks/mailto/js_form/handlebars-v4.0.4.js, blocks/mailto/js_form/html.sortable.min.js, blocks/mailto/js_form, blocks/mailto/controller.php, blocks/mailto/composer.php, blocks/mailto, blocks/drawing_record_v_one_point_two_production/db.xml, blocks/drawing_record_v_one_point_two_production/edit.php, blocks/drawing_record_v_one_point_two_production/config.json, blocks/drawing_record_v_one_point_two_production/icon.png, blocks/drawing_record_v_one_point_two_production/add.php, blocks/drawing_record_v_one_point_two_production/view.php, blocks/drawing_record_v_one_point_two_production/form.php, blocks/drawing_record_v_one_point_two_production/controller.php, blocks/drawing_record_v_one_point_two_production/composer.php, blocks/drawing_record_v_one_point_two_production, blocks/ablocka/db.xml, blocks/ablocka/edit.php, blocks/ablocka/config.json, blocks/ablocka/icon.png, blocks/ablocka/add.php, blocks/ablocka/view.php, blocks/ablocka/form.php, blocks/ablocka/controller.php, blocks/ablocka/composer.php, blocks/ablocka, blocks/drawing_record_v_one_point_one/db.xml, blocks/drawing_record_v_one_point_one/edit.php, blocks/drawing_record_v_one_point_one/config.json, blocks/drawing_record_v_one_point_one/icon.png, blocks/drawing_record_v_one_point_one/add.php, blocks/drawing_record_v_one_point_one/view.php, blocks/drawing_record_v_one_point_one/form.php, blocks/drawing_record_v_one_point_one/controller.php, blocks/drawing_record_v_one_point_one/composer.php, blocks/drawing_record_v_one_point_one, blocks/documentupload/db.xml, blocks/documentupload/edit.php, blocks/documentupload/config.json, blocks/documentupload/icon.png, blocks/documentupload/add.php, blocks/documentupload/view.php, blocks/documentupload/form.php, blocks/documentupload/controller.php, blocks/documentupload/composer.php, blocks/documentupload, blocks/drawing_record_v_one_point_two/db.xml, blocks/drawing_record_v_one_point_two/edit.php, blocks/drawing_record_v_one_point_two/config.json, blocks/drawing_record_v_one_point_two/icon.png, blocks/drawing_record_v_one_point_two/add.php, blocks/drawing_record_v_one_point_two/view.php, blocks/drawing_record_v_one_point_two/form.php, blocks/drawing_record_v_one_point_two/controller.php, blocks/drawing_record_v_one_point_two/composer.php, blocks/drawing_record_v_one_point_two, blocks/ablockb/db.xml, blocks/ablockb/edit.php, blocks/ablockb/config.json, blocks/ablockb/icon.png, blocks/ablockb/add.php, blocks/ablockb/view.php, blocks/ablockb/form.php, blocks/ablockb/controller.php, blocks/ablockb/composer.php, blocks/ablockb, blocks/ablock/db.xml, blocks/ablock/edit.php, blocks/ablock/config.json, blocks/ablock/icon.png, blocks/ablock/add.php, blocks/ablock/view.php, blocks/ablock/form.php, blocks/ablock/controller.php, blocks/ablock/composer.php, blocks/ablock, blocks/distribute_url_by_mail/db.xml, blocks/distribute_url_by_mail/edit.php, blocks/distribute_url_by_mail/config.json, blocks/distribute_url_by_mail/icon.png, blocks/distribute_url_by_mail/add.php, blocks/distribute_url_by_mail/view.php, blocks/distribute_url_by_mail/form.php, blocks/distribute_url_by_mail/controller.php, blocks/distribute_url_by_mail/composer.php, blocks/distribute_url_by_mail, blocks/drawing_record_v_one/db.xml, blocks/drawing_record_v_one/edit.php, blocks/drawing_record_v_one/config.json, blocks/drawing_record_v_one/icon.png, blocks/drawing_record_v_one/add.php, blocks/drawing_record_v_one/view.php, blocks/drawing_record_v_one/form.php, blocks/drawing_record_v_one/controller.php, blocks/drawing_record_v_one/composer.php, blocks/drawing_record_v_one, blocks/drawing_record_v_one_point_one_production/db.xml, blocks/drawing_record_v_one_point_one_production/edit.php, blocks/drawing_record_v_one_point_one_production/config.json, blocks/drawing_record_v_one_point_one_production/icon.png, blocks/drawing_record_v_one_point_one_production/add.php, blocks/drawing_record_v_one_point_one_production/view.php, blocks/drawing_record_v_one_point_one_production/form.php, blocks/drawing_record_v_one_point_one_production/controller.php, blocks/drawing_record_v_one_point_one_production/composer.php, blocks/drawing_record_v_one_point_one_production, languages/pl_PL/LC_MESSAGES/messages.mo, languages/pl_PL/LC_MESSAGES, languages/pl_PL, languages/fr_FR/LC_MESSAGES/messages.mo, languages/fr_FR/LC_MESSAGES, languages/fr_FR, languages/it_IT/LC_MESSAGES/messages.mo, languages/it_IT/LC_MESSAGES, languages/it_IT, languages/pt_BR/LC_MESSAGES/messages.mo, languages/pt_BR/LC_MESSAGES, languages/pt_BR, languages/ru_RU/LC_MESSAGES/messages.mo, languages/ru_RU/LC_MESSAGES, languages/ru_RU, languages/nl_NL/LC_MESSAGES/messages.mo, languages/nl_NL/LC_MESSAGES, languages/nl_NL, languages/da_DK/LC_MESSAGES/messages.mo, languages/da_DK/LC_MESSAGES, languages/da_DK, languages/nb_NO/LC_MESSAGES/messages.mo, languages/nb_NO/LC_MESSAGES, languages/nb_NO, languages/ja_JP/LC_MESSAGES/messages.mo, languages/ja_JP/LC_MESSAGES, languages/ja_JP, languages/sv_SE/LC_MESSAGES/messages.mo, languages/sv_SE/LC_MESSAGES, languages/sv_SE, languages/tr_TR/LC_MESSAGES/messages.mo, languages/tr_TR/LC_MESSAGES, languages/tr_TR, languages/de_DE/LC_MESSAGES/messages.mo, languages/de_DE/LC_MESSAGES, languages/de_DE, languages/el_GR/LC_MESSAGES/messages.mo, languages/el_GR/LC_MESSAGES, languages/el_GR, languages/fi_FI/LC_MESSAGES/messages.mo, languages/fi_FI/LC_MESSAGES, languages/fi_FI, languages/es_PY/LC_MESSAGES/messages.mo, languages/es_PY/LC_MESSAGES, languages/es_PY, blocks/mailto/db.xml, blocks/mailto/css_form/repeatable-ft.form.css, blocks/mailto/css_form, blocks/mailto/edit.php, blocks/mailto/config.json, blocks/mailto/icon.png, blocks/mailto/add.php, blocks/mailto/view.php, blocks/mailto/auto.js, blocks/mailto/form.php, blocks/mailto/js_form/handlebars-helpers.js, blocks/mailto/js_form/handlebars-v4.0.4.js, blocks/mailto/js_form/html.sortable.min.js, blocks/mailto/js_form, blocks/mailto/controller.php, blocks/mailto/composer.php, blocks/mailto, blocks/drawing_record_v_one_point_two_production/db.xml, blocks/drawing_record_v_one_point_two_production/edit.php, blocks/drawing_record_v_one_point_two_production/config.json, blocks/drawing_record_v_one_point_two_production/icon.png, blocks/drawing_record_v_one_point_two_production/add.php, blocks/drawing_record_v_one_point_two_production/view.php, blocks/drawing_record_v_one_point_two_production/form.php, blocks/drawing_record_v_one_point_two_production/controller.php, blocks/drawing_record_v_one_point_two_production/composer.php, blocks/drawing_record_v_one_point_two_production, blocks/ablocka/db.xml, blocks/ablocka/edit.php, blocks/ablocka/config.json, blocks/ablocka/icon.png, blocks/ablocka/add.php, blocks/ablocka/view.php, blocks/ablocka/form.php, blocks/ablocka/controller.php, blocks/ablocka/composer.php, blocks/ablocka, blocks/drawing_record_v_one_point_one/db.xml, blocks/drawing_record_v_one_point_one/edit.php, blocks/drawing_record_v_one_point_one/config.json, blocks/drawing_record_v_one_point_one/icon.png, blocks/drawing_record_v_one_point_one/add.php, blocks/drawing_record_v_one_point_one/view.php, blocks/drawing_record_v_one_point_one/form.php, blocks/drawing_record_v_one_point_one/controller.php, blocks/drawing_record_v_one_point_one/composer.php, blocks/drawing_record_v_one_point_one, blocks/documentupload/db.xml, blocks/documentupload/edit.php, blocks/documentupload/config.json, blocks/documentupload/icon.png, blocks/documentupload/add.php, blocks/documentupload/view.php, blocks/documentupload/form.php, blocks/documentupload/controller.php, blocks/documentupload/composer.php, blocks/documentupload, blocks/drawing_record_v_one_point_two/db.xml, blocks/drawing_record_v_one_point_two/edit.php, blocks/drawing_record_v_one_point_two/config.json, blocks/drawing_record_v_one_point_two/icon.png, blocks/drawing_record_v_one_point_two/add.php, blocks/drawing_record_v_one_point_two/view.php, blocks/drawing_record_v_one_point_two/form.php, blocks/drawing_record_v_one_point_two/controller.php, blocks/drawing_record_v_one_point_two/composer.php, blocks/drawing_record_v_one_point_two, blocks/ablockb/db.xml, blocks/ablockb/edit.php, blocks/ablockb/config.json, blocks/ablockb/icon.png, blocks/ablockb/add.php, blocks/ablockb/view.php, blocks/ablockb/form.php, blocks/ablockb/controller.php, blocks/ablockb/composer.php, blocks/ablockb, blocks/ablock/db.xml, blocks/ablock/edit.php, blocks/ablock/config.json, blocks/ablock/icon.png, blocks/ablock/add.php, blocks/ablock/view.php, blocks/ablock/form.php, blocks/ablock/controller.php, blocks/ablock/composer.php, blocks/ablock, blocks/distribute_url_by_mail/db.xml, blocks/distribute_url_by_mail/edit.php, blocks/distribute_url_by_mail/config.json, blocks/distribute_url_by_mail/icon.png, blocks/distribute_url_by_mail/add.php, blocks/distribute_url_by_mail/view.php, blocks/distribute_url_by_mail/form.php, blocks/distribute_url_by_mail/controller.php, blocks/distribute_url_by_mail/composer.php, blocks/distribute_url_by_mail, blocks/drawing_record_v_one/db.xml, blocks/drawing_record_v_one/edit.php, blocks/drawing_record_v_one/config.json, blocks/drawing_record_v_one/icon.png, blocks/drawing_record_v_one/add.php, blocks/drawing_record_v_one/view.php, blocks/drawing_record_v_one/form.php, blocks/drawing_record_v_one/controller.php, blocks/drawing_record_v_one/composer.php, blocks/drawing_record_v_one, blocks/drawing_record_v_one_point_one_production/db.xml, blocks/drawing_record_v_one_point_one_production/edit.php, blocks/drawing_record_v_one_point_one_production/config.json, blocks/drawing_record_v_one_point_one_production/icon.png, blocks/drawing_record_v_one_point_one_production/add.php, blocks/drawing_record_v_one_point_one_production/view.php, blocks/drawing_record_v_one_point_one_production/form.php, blocks/drawing_record_v_one_point_one_production/controller.php, blocks/drawing_record_v_one_point_one_production/composer.php, blocks/drawing_record_v_one_point_one_production, languages/pl_PL/LC_MESSAGES/messages.mo, languages/pl_PL/LC_MESSAGES, languages/pl_PL, languages/fr_FR/LC_MESSAGES/messages.mo, languages/fr_FR/LC_MESSAGES, languages/fr_FR, languages/it_IT/LC_MESSAGES/messages.mo, languages/it_IT/LC_MESSAGES, languages/it_IT, languages/pt_BR/LC_MESSAGES/messages.mo, languages/pt_BR/LC_MESSAGES, languages/pt_BR, languages/ru_RU/LC_MESSAGES/messages.mo, languages/ru_RU/LC_MESSAGES, languages/ru_RU, languages/nl_NL/LC_MESSAGES/messages.mo, languages/nl_NL/LC_MESSAGES, languages/nl_NL, languages/da_DK/LC_MESSAGES/messages.mo, languages/da_DK/LC_MESSAGES, languages/da_DK, languages/nb_NO/LC_MESSAGES/messages.mo, languages/nb_NO/LC_MESSAGES, languages/nb_NO, languages/ja_JP/LC_MESSAGES/messages.mo, languages/ja_JP/LC_MESSAGES, languages/ja_JP, languages/sv_SE/LC_MESSAGES/messages.mo, languages/sv_SE/LC_MESSAGES, languages/sv_SE, languages/tr_TR/LC_MESSAGES/messages.mo, languages/tr_TR/LC_MESSAGES, languages/tr_TR, languages/de_DE/LC_MESSAGES/messages.mo, languages/de_DE/LC_MESSAGES, languages/de_DE, languages/el_GR/LC_MESSAGES/messages.mo, languages/el_GR/LC_MESSAGES, languages/el_GR, languages/fi_FI/LC_MESSAGES/messages.mo, languages/fi_FI/LC_MESSAGES, languages/fi_FI, languages/es_PY/LC_MESSAGES/messages.mo, languages/es_PY/LC_MESSAGES, languages/es_PY

# concrete5 Cache Settings
Block Cache - On
Overrides Cache - On
Full Page Caching - Off
Full Page Cache Lifetime - Every 6 hours (default setting).

# Server Software
Apache/2.4.18 (Unix) OpenSSL/1.0.1e-fips mod_bwlimited/1.4

# Server API
cgi-fcgi

# PHP Version
5.5.33

# PHP Extensions
bcmath, bz2, calendar, cgi-fcgi, Core, ctype, curl, date, dom, enchant, ereg, exif, fileinfo, filter, ftp, gd, gettext, hash, iconv, imap, intl, ionCube Loader, json, libxml, mbstring, mcrypt, mysql, mysqli, mysqlnd, openssl, pcre, PDO, pdo_mysql, pdo_sqlite, Phar, posix, pspell, Reflection, session, SimpleXML, soap, sockets, SourceGuardian, SPL, sqlite3, standard, tidy, tokenizer, wddx, xml, xmlreader, xmlrpc, xmlwriter, xsl, Zend Guard Loader, Zend OPcache, zip, zlib.

# PHP Settings
max_execution_time - 30
log_errors_max_len - 1024
max_file_uploads - 20
max_input_nesting_level - 64
max_input_time - 60
max_input_vars - 1000
memory_limit - 128M
post_max_size - 105M
sql.safe_mode - Off
upload_max_filesize - 105M
mysql.max_links - Unlimited
mysql.max_persistent - Unlimited
mysqli.max_links - Unlimited
mysqli.max_persistent - Unlimited
pcre.backtrack_limit - 1000000
pcre.recursion_limit - 100000
session.cache_limiter - <i>no value</i>
session.gc_maxlifetime - 1440
soap.wsdl_cache_limit - 5
opcache.max_accelerated_files - 2000
opcache.max_file_size - 0
opcache.max_wasted_percentage - 5

Browser User-Agent String

Mozilla/5.0 (Windows NT 6.1; WOW64; Trident/7.0; rv:11.0) like Gecko

Hide Post Content

This will replace the post content with the message: "Content has been removed by an Administrator"

Hide Content

Request Refund

You may not request a refund that is not currently owned by you.