Programmatically set Event attribute

Permalink Browser Info Environment
Hey guys,

I was wondering if it was possibile to programmatically set an existing Event attribute similarly to how we set other attributes in concrete5. For example $c->setAttribute('attribute_handle', 'attribute_value');

The attribute has been already created through the CMS, I just need a way to set the value programmatically.

I tried reusing some code I in the files, for example:

$ak = EventKey::getByHandle('calendar_event_client_booked_id');
$akID = $ak->getAttributeKeyID();
$new_value = $ak->addAttributeValue();
$new_value->setValue('45');
$value = EventValue::getByID($new_value->getAttributeValueID());
$value->setEvent($event);
$db = \Database::connection();
 $db->Replace(
                    'CalendarEventAttributeValues',
                    array(
                        'eventID'  => $event->getID(),
                        'akID' => $ak->getAttributeKeyID(),
                        'avID' => $value->getAttributeValueID()
                    ),
                    array('eventID', 'akID'));

Type: Discussion
Status: In Progress
marcoacciarri
View Replies:
Chrouglas replied on at Permalink Reply
Chrouglas
Hey there Marco. I know this is an old thread but did you by chance find a solutions to this? I'd like to have the calendar events displayed normally but with an option for registered users to edit an attribute right on the calendar. Specifically, I want users to be able to add their names to volunteer for that particular event.

Thanks in advance.
C

concrete5 Environment Information

# concrete5 Version
Core Version - 8.2.1
Version Installed - 8.2.1
Database Version - 20170802000000

# concrete5 Packages
Calendar (1.1.6), ExchangeCore reCAPTCHA (1.1.1), Styled Maps (1.2.0)

# concrete5 Overrides
blocks/autonav/templates/footer/view.php, blocks/autonav/templates/footer, blocks/autonav/templates/sidebar/build/view.js, blocks/autonav/templates/sidebar/build, blocks/autonav/templates/sidebar/view.js, blocks/autonav/templates/sidebar/view.php, blocks/autonav/templates/sidebar, blocks/autonav/templates, blocks/autonav, blocks/bd_featurette/add.php, blocks/bd_featurette/auto.css, blocks/bd_featurette/auto.js, blocks/bd_featurette/build/_import.scss, blocks/bd_featurette/build/view.scss, blocks/bd_featurette/build, blocks/bd_featurette/composer.php, blocks/bd_featurette/config.json, blocks/bd_featurette/controller.php, blocks/bd_featurette/db.xml, blocks/bd_featurette/edit.php, blocks/bd_featurette/form.php, blocks/bd_featurette/icon.png, blocks/bd_featurette/templates/header.php, blocks/bd_featurette/templates/home_cta.php, blocks/bd_featurette/templates, blocks/bd_featurette/view.css, blocks/bd_featurette/view.php, blocks/bd_featurette, blocks/calendar/controller.php, blocks/calendar/view.php, blocks/calendar, blocks/content/controller.php, blocks/content/view.php, blocks/content, blocks/express_entry_detail/controller.php, blocks/express_entry_detail/templates/sessions_past/view.php, blocks/express_entry_detail/templates/sessions_past, blocks/express_entry_detail/templates/sessions_upcoming/view.php, blocks/express_entry_detail/templates/sessions_upcoming, blocks/express_entry_detail/templates, blocks/express_entry_detail/view.php, blocks/express_entry_detail, blocks/express_entry_list/controller.php, blocks/express_entry_list/templates/sessions_upcoming/view.php, blocks/express_entry_list/templates/sessions_upcoming, blocks/express_entry_list/templates/tutors/view.php, blocks/express_entry_list/templates/tutors, blocks/express_entry_list/templates, blocks/express_entry_list, blocks/form/build/js/validation.js, blocks/form/build/js, blocks/form/build, blocks/form/controller.php, blocks/form/header.php, blocks/form/js/validation.js, blocks/form/js, blocks/form/templates/newsletter/build/_import.scss, blocks/form/templates/newsletter/build/view.scss, blocks/form/templates/newsletter/build, blocks/form/templates/newsletter/view.css, blocks/form/templates/newsletter/view.php, blocks/form/templates/newsletter, blocks/form/templates, blocks/form/view.php, blocks/form, blocks/image/build/view.js, blocks/image/build, blocks/image/controller.php, blocks/image/templates/above_the_fold/view.php, blocks/image/templates/above_the_fold, blocks/image/templates/lazyload/view.php, blocks/image/templates/lazyload, blocks/image/templates, blocks/image/view.js, blocks/image/view.php, blocks/image, blocks/image_slider/build/js/custom-responsive-slides.js, blocks/image_slider/build/js, blocks/image_slider/build/view.js, blocks/image_slider/build, blocks/image_slider/js/custom-responsive-slides.js, blocks/image_slider/js, blocks/image_slider/templates/carousel/build/view.js, blocks/image_slider/templates/carousel/build, blocks/image_slider/templates/carousel/view.js, blocks/image_slider/templates/carousel/view.php, blocks/image_slider/templates/carousel, blocks/image_slider/templates, blocks/image_slider/view.js, blocks/image_slider/view.php, blocks/image_slider, blocks/page_list/templates/header/view.php, blocks/page_list/templates/header, blocks/page_list/templates, blocks/page_list, blocks/page_title/view.php, blocks/page_title, blocks/search/view.php, blocks/search, blocks/styled_maps/templates/home/build/_import.scss, blocks/styled_maps/templates/home/build/view.scss, blocks/styled_maps/templates/home/build, blocks/styled_maps/templates/home/view.css, blocks/styled_maps/templates/home/view.php, blocks/styled_maps/templates/home, blocks/styled_maps/templates, blocks/styled_maps/view.php, blocks/styled_maps, controllers/page_types/default_page.php, controllers/page_types/entry.php, controllers/page_types/home.php, controllers/page_types/tutors.php, controllers/page_types, controllers/single_page/dashboard/system/attributes.php, controllers/single_page/dashboard/system/optimization.php, controllers/single_page/dashboard/system/seo.php, controllers/single_page/dashboard/system, controllers/single_page/dashboard, controllers/single_page/login.php, controllers/single_page/members/profile.php, controllers/single_page/members, controllers/single_page/page_not_found.php, controllers/single_page/shop.php, controllers/single_page, elements/custom_footer_required.php, elements/custom_header_required.php, elements/events, elements/modules/disabled_item.php, elements/modules/image_hover.php, elements/modules/preloader.php, elements/modules, elements/permission, css/build, css/concrete/build/_import.scss, css/concrete/build/login.scss, css/concrete/build, css/concrete/login.css, css/concrete, css/import.scss, css/vendor, js/ec_recaptcha/build/render.js, js/ec_recaptcha/build, js/ec_recaptcha/render.js, js/ec_recaptcha, js/utilities/build/enable_ssl.js, js/utilities/build, js/utilities/enable_ssl.js, js/utilities, js/vendor/jquery-picturefill.js, js/vendor/jquery-throttle.js, js/vendor/jquery-unveil.js, js/vendor, single_pages/dashboard/calendar, single_pages/dashboard/google-analytics.php, single_pages/dashboard/system/seo/google-analytics.php, single_pages/dashboard/system/seo, single_pages/dashboard/system, single_pages/dashboard, single_pages/login.php, single_pages/members/profile.php, single_pages/members, single_pages/shop.php, themes/concrete/background_image.php, themes/concrete/images/header-logo.png, themes/concrete/images, themes/concrete/main.css, themes/concrete, themes/main/css/all.css, themes/main/css/build/sass/all.scss, themes/main/css/build/sass/base/_index.scss, themes/main/css/build/sass/base/_reset.scss, themes/main/css/build/sass/base/_setup.scss, themes/main/css/build/sass/base/_typography.scss, themes/main/css/build/sass/base, themes/main/css/build/sass/blocks/_autonav.scss, themes/main/css/build/sass/blocks/_content.scss, themes/main/css/build/sass/blocks/_image.scss, themes/main/css/build/sass/blocks/_image_slider.scss, themes/main/css/build/sass/blocks/_index.scss, themes/main/css/build/sass/blocks/_page_title.scss, themes/main/css/build/sass/blocks/_search.scss, themes/main/css/build/sass/blocks, themes/main/css/build/sass/components/_accordion.scss, themes/main/css/build/sass/components/_blocks.scss, themes/main/css/build/sass/components/_buttons.scss, themes/main/css/build/sass/components/_extends.scss, themes/main/css/build/sass/components/_forms.scss, themes/main/css/build/sass/components/_grid.scss, themes/main/css/build/sass/components/_helpers.scss, themes/main/css/build/sass/components/_index.scss, themes/main/css/build/sass/components/_pagination.scss, themes/main/css/build/sass/components, themes/main/css/build/sass/default.scss, themes/main/css/build/sass/default_inline.scss, themes/main/css/build/sass/home.scss, themes/main/css/build/sass/home_inline.scss, themes/main/css/build/sass/layouts/_aside.scss, themes/main/css/build/sass/layouts/_extends.scss, themes/main/css/build/sass/layouts/_footer.scss, themes/main/css/build/sass/layouts/_header.scss, themes/main/css/build/sass/layouts/_index.scss, themes/main/css/build/sass/layouts/_main.scss, themes/main/css/build/sass/layouts, themes/main/css/build/sass/login.scss, themes/main/css/build/sass/modules/_image_hover.scss, themes/main/css/build/sass/modules/_index.scss, themes/main/css/build/sass/modules/_preloader.scss, themes/main/css/build/sass/modules/_tutor_list.scss, themes/main/css/build/sass/modules, themes/main/css/build/sass/presets/_defaults.scss, themes/main/css/build/sass/presets, themes/main/css/build/sass/states/_collapse.scss, themes/main/css/build/sass/states/_index.scss, themes/main/css/build/sass/states/_viewport.scss, themes/main/css/build/sass/states, themes/main/css/build/sass/typography.scss, themes/main/css/build/sass/utilities/_bem.scss, themes/main/css/build/sass/utilities/_css3.scss, themes/main/css/build/sass/utilities/_fonts.scss, themes/main/css/build/sass/utilities/_functions.scss, themes/main/css/build/sass/utilities/_index.scss, themes/main/css/build/sass/utilities/_media_queries.scss, themes/main/css/build/sass/utilities/_mixins.scss, themes/main/css/build/sass/utilities, themes/main/css/build/sass/vendor/_bootstrap.scss, themes/main/css/build/sass/vendor/_concrete5.scss, themes/main/css/build/sass/vendor/_fontawesome.scss, themes/main/css/build/sass/vendor/_index.scss, themes/main/css/build/sass/vendor/_responsive-slides.scss, themes/main/css/build/sass/vendor/bootstrap/_alerts.scss, themes/main/css/build/sass/vendor/bootstrap/_badges.scss, themes/main/css/build/sass/vendor/bootstrap/_breadcrumbs.scss, themes/main/css/build/sass/vendor/bootstrap/_button-groups.scss, themes/main/css/build/sass/vendor/bootstrap/_buttons.scss, themes/main/css/build/sass/vendor/bootstrap/_carousel.scss, themes/main/css/build/sass/vendor/bootstrap/_close.scss, themes/main/css/build/sass/vendor/bootstrap/_code.scss, themes/main/css/build/sass/vendor/bootstrap/_component-animations.scss, themes/main/css/build/sass/vendor/bootstrap/_datepicker.scss, themes/main/css/build/sass/vendor/bootstrap/_dropdowns.scss, themes/main/css/build/sass/vendor/bootstrap/_forms.scss, themes/main/css/build/sass/vendor/bootstrap/_glyphicons.scss, themes/main/css/build/sass/vendor/bootstrap/_grid.scss, themes/main/css/build/sass/vendor/bootstrap/_input-groups.scss, themes/main/css/build/sass/vendor/bootstrap/_jumbotron.scss, themes/main/css/build/sass/vendor/bootstrap/_labels.scss, themes/main/css/build/sass/vendor/bootstrap/_list-group.scss, themes/main/css/build/sass/vendor/bootstrap/_media.scss, themes/main/css/build/sass/vendor/bootstrap/_mixins.scss, themes/main/css/build/sass/vendor/bootstrap/_modals.scss, themes/main/css/build/sass/vendor/bootstrap/_navbar.scss, themes/main/css/build/sass/vendor/bootstrap/_navs.scss, themes/main/css/build/sass/vendor/bootstrap/_normalize.scss, themes/main/css/build/sass/vendor/bootstrap/_pager.scss, themes/main/css/build/sass/vendor/bootstrap/_pagination.scss, themes/main/css/build/sass/vendor/bootstrap/_panels.scss, themes/main/css/build/sass/vendor/bootstrap/_popovers.scss, themes/main/css/build/sass/vendor/bootstrap/_print.scss, themes/main/css/build/sass/vendor/bootstrap/_progress-bars.scss, themes/main/css/build/sass/vendor/bootstrap/_responsive-embed.scss, themes/main/css/build/sass/vendor/bootstrap/_responsive-utilities.scss, themes/main/css/build/sass/vendor/bootstrap/_scaffolding.scss, themes/main/css/build/sass/vendor/bootstrap/_tables.scss, themes/main/css/build/sass/vendor/bootstrap/_theme.scss, themes/main/css/build/sass/vendor/bootstrap/_thumbnails.scss, themes/main/css/build/sass/vendor/bootstrap/_tooltip.scss, themes/main/css/build/sass/vendor/bootstrap/_type.scss, themes/main/css/build/sass/vendor/bootstrap/_utilities.scss, themes/main/css/build/sass/vendor/bootstrap/_variables-custom.scss, themes/main/css/build/sass/vendor/bootstrap/_variables.scss, themes/main/css/build/sass/vendor/bootstrap/_wells.scss, themes/main/css/build/sass/vendor/bootstrap/mixins/_alerts.scss, themes/main/css/build/sass/vendor/bootstrap/mixins/_background-variant.scss, themes/main/css/build/sass/vendor/bootstrap/mixins/_border-radius.scss, themes/main/css/build/sass/vendor/bootstrap/mixins/_buttons.scss, themes/main/css/build/sass/vendor/bootstrap/mixins/_center-block.scss, themes/main/css/build/sass/vendor/bootstrap/mixins/_clearfix.scss, themes/main/css/build/sass/vendor/bootstrap/mixins/_forms.scss, themes/main/css/build/sass/vendor/bootstrap/mixins/_gradients.scss, themes/main/css/build/sass/vendor/bootstrap/mixins/_grid-framework.scss, themes/main/css/build/sass/vendor/bootstrap/mixins/_grid.scss, themes/main/css/build/sass/vendor/bootstrap/mixins/_hide-text.scss, themes/main/css/build/sass/vendor/bootstrap/mixins/_image.scss, themes/main/css/build/sass/vendor/bootstrap/mixins/_labels.scss, themes/main/css/build/sass/vendor/bootstrap/mixins/_list-group.scss, themes/main/css/build/sass/vendor/bootstrap/mixins/_nav-divider.scss, themes/main/css/build/sass/vendor/bootstrap/mixins/_nav-vertical-align.scss, themes/main/css/build/sass/vendor/bootstrap/mixins/_opacity.scss, themes/main/css/build/sass/vendor/bootstrap/mixins/_pagination.scss, themes/main/css/build/sass/vendor/bootstrap/mixins/_panels.scss, themes/main/css/build/sass/vendor/bootstrap/mixins/_progress-bar.scss, themes/main/css/build/sass/vendor/bootstrap/mixins/_reset-filter.scss, themes/main/css/build/sass/vendor/bootstrap/mixins/_reset-text.scss, themes/main/css/build/sass/vendor/bootstrap/mixins/_resize.scss, themes/main/css/build/sass/vendor/bootstrap/mixins/_responsive-visibility.scss, themes/main/css/build/sass/vendor/bootstrap/mixins/_size.scss, themes/main/css/build/sass/vendor/bootstrap/mixins/_tab-focus.scss, themes/main/css/build/sass/vendor/bootstrap/mixins/_table-row.scss, themes/main/css/build/sass/vendor/bootstrap/mixins/_text-emphasis.scss, themes/main/css/build/sass/vendor/bootstrap/mixins/_text-overflow.scss, themes/main/css/build/sass/vendor/bootstrap/mixins/_vendor-prefixes-bs.scss, themes/main/css/build/sass/vendor/bootstrap/mixins/_vendor-prefixes.scss, themes/main/css/build/sass/vendor/bootstrap/mixins, themes/main/css/build/sass/vendor/bootstrap, themes/main/css/build/sass/vendor/fontawesome/_animated.scss, themes/main/css/build/sass/vendor/fontawesome/_bordered-pulled.scss, themes/main/css/build/sass/vendor/fontawesome/_core.scss, themes/main/css/build/sass/vendor/fontawesome/_fixed-width.scss, themes/main/css/build/sass/vendor/fontawesome/_icons.scss, themes/main/css/build/sass/vendor/fontawesome/_larger.scss, themes/main/css/build/sass/vendor/fontawesome/_list.scss, themes/main/css/build/sass/vendor/fontawesome/_mixins.scss, themes/main/css/build/sass/vendor/fontawesome/_path.scss, themes/main/css/build/sass/vendor/fontawesome/_rotated-flipped.scss, themes/main/css/build/sass/vendor/fontawesome/_screen-reader.scss, themes/main/css/build/sass/vendor/fontawesome/_stacked.scss, themes/main/css/build/sass/vendor/fontawesome/_variables.scss, themes/main/css/build/sass/vendor/fontawesome, themes/main/css/build/sass/vendor, themes/main/css/build/sass, themes/main/css/build, themes/main/css/default.css, themes/main/css/default_inline.css, themes/main/css/home.css, themes/main/css/home_inline.css, themes/main/css/login.css, themes/main/css/styles.xml, themes/main/css/typography.css, themes/main/css, themes/main/default.php, themes/main/elements/footer.php, themes/main/elements/header.php, themes/main/elements, themes/main/entry.php, themes/main/fonts/Montserrat-Bold.eot, themes/main/fonts/Montserrat-Bold.svg, themes/main/fonts/Montserrat-Bold.ttf, themes/main/fonts/Montserrat-Bold.woff, themes/main/fonts/Montserrat-Bold.woff2, themes/main/fonts/OpenSans-Bold.eot, themes/main/fonts/OpenSans-Bold.svg, themes/main/fonts/OpenSans-Bold.ttf, themes/main/fonts/OpenSans-Bold.woff, themes/main/fonts/OpenSans-Bold.woff2, themes/main/fonts/OpenSans-Regular.eot, themes/main/fonts/OpenSans-Regular.svg, themes/main/fonts/OpenSans-Regular.ttf, themes/main/fonts/OpenSans-Regular.woff, themes/main/fonts/OpenSans-Regular.woff2, themes/main/fonts/PTSerif-Bold.eot, themes/main/fonts/PTSerif-Bold.svg, themes/main/fonts/PTSerif-Bold.ttf, themes/main/fonts/PTSerif-Bold.woff, themes/main/fonts/PTSerif-Bold.woff2, themes/main/fonts/PTSerif-Regular.eot, themes/main/fonts/PTSerif-Regular.svg, themes/main/fonts/PTSerif-Regular.ttf, themes/main/fonts/PTSerif-Regular.woff, themes/main/fonts/PTSerif-Regular.woff2, themes/main/fonts/slick.eot, themes/main/fonts/slick.svg, themes/main/fonts/slick.ttf, themes/main/fonts/slick.woff, themes/main/fonts, themes/main/home.php, themes/main/images/arrow_purple_down.png, themes/main/images/components/accordion-arrow--down.png, themes/main/images/components/accordion-arrow--up.png, themes/main/images/components, themes/main/images/header-logo.png, themes/main/images/logo.png, themes/main/images/responsive-slides/arrows.png, themes/main/images/responsive-slides, themes/main/images/splash_bg.jpg, themes/main/images, themes/main/js/_compiled/components/accordion.js, themes/main/js/_compiled/components, themes/main/js/_compiled/modules/image_hover.js, themes/main/js/_compiled/modules, themes/main/js/_compiled/plugins.js, themes/main/js/_compiled/scripts.js, themes/main/js/_compiled, themes/main/js/application.js, themes/main/js/build/components/accordion.js, themes/main/js/build/components, themes/main/js/build/modules/image_hover.js, themes/main/js/build/modules, themes/main/js/build/plugins.js, themes/main/js/build/scripts.js, themes/main/js/build, themes/main/js/editor/config.js, themes/main/js/editor/images/feature.gif, themes/main/js/editor/images/header_accordion.gif, themes/main/js/editor/images/template1.gif, themes/main/js/editor/images/template2.gif, themes/main/js/editor/images/template3.gif, themes/main/js/editor/images/testimonial.gif, themes/main/js/editor/images, themes/main/js/editor/styles.js, themes/main/js/editor/templates.js, themes/main/js/editor, themes/main/js, themes/main/page_forbidden.php, themes/main/page_not_found.php, themes/main/page_theme.php, themes/main/thumbnail.png, themes/main/tutors.php, themes/main/view.php, themes/main, views/dialog/event/frontend, views/dialog/event, views/dialog, views/frontend/maintenance_mode.php, views/frontend, src/Cache/Page/MemcachedPageCache.php, src/Cache/Page, src/Cache, src/Concrete/Captcha, src/Concrete/Editor/CkeditorEditor.php, src/Concrete/Editor/EditorServiceProvider.php, src/Concrete/Editor/LinkAbstractor.php, src/Concrete/Editor, src/Concrete/File/Importer.php, src/Concrete/File, src/Concrete/Helper/UserInterface.php, src/Concrete/Helper, src/Concrete/Html/Image.php, src/Concrete/Html/Object/Picture.php, src/Concrete/Html/Object, src/Concrete/Html, src/Concrete/Page/Controller/PageController.php, src/Concrete/Page/Controller/PageTypeController.php, src/Concrete/Page/Controller, src/Concrete/Page, src/Concrete/Session/SessionFactory.php, src/Concrete/Session, src/Concrete, src/Events/FileVersions.php, src/Events/User.php, src/Events, src/Helper/Slack.php, src/Helper

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

# Server Software
Apache/2.2.29 (Unix) mod_wsgi/3.5 Python/2.7.10 PHP/5.6.10 mod_ssl/2.2.29 OpenSSL/0.9.8zh DAV/2 mod_fastcgi/2.4.6 mod_perl/2.0.9 Perl/v5.22.0

# Server API
apache2handler

# PHP Version
5.6.10

# PHP Extensions
apache2handler, bcmath, bz2, calendar, Core, ctype, curl, date, dom, ereg, exif, fileinfo, filter, ftp, gd, gettext, hash, iconv, imap, intl, json, ldap, libxml, mbstring, mcrypt, mysql, mysqli, mysqlnd, openssl, pcre, PDO, pdo_mysql, pdo_pgsql, pdo_sqlite, pgsql, Phar, posix, Reflection, session, SimpleXML, soap, sockets, SPL, sqlite3, standard, tokenizer, wddx, xml, xmlreader, xmlwriter, xsl, yaz, 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 - 32M
sql.safe_mode - Off
upload_max_filesize - 32M
ldap.max_links - Unlimited
mysql.max_links - Unlimited
mysql.max_persistent - Unlimited
mysqli.max_links - Unlimited
mysqli.max_persistent - Unlimited
pcre.backtrack_limit - 1000000
pcre.recursion_limit - 100000
pgsql.max_links - Unlimited
pgsql.max_persistent - Unlimited
session.cache_limiter - <i>no value</i>
session.gc_maxlifetime - 7200
soap.wsdl_cache_limit - 5

Browser User-Agent String

Mozilla/5.0 (Macintosh; Intel Mac OS X 10_11_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/60.0.3112.101 Safari/537.36

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.