Invision Community 4: SEO, prepare for v5 and dormant account notifications By Matt Monday at 02:04 PM
bradl Posted February 25, 2016 Posted February 25, 2016 If I have a couple of custom blocks that are record feeds from each category in a database, how would I add an "Add Record" button to the end of each block template that launches the database form to add a record to that category?
bradl Posted February 26, 2016 Author Posted February 26, 2016 Meh, I added hardcoded links for now. <div class="ipsType_center"><a class="ipsButton ipsButton_important" href="http://www.example.com/recipes/category_name/?do=form&d=5">Add Recipe</a></div>
TAMAN Posted February 26, 2016 Posted February 26, 2016 I havent tested but this is this is the add record link i took it out from default templates so give it a try it should work <a class="ipsButton ipsButton_medium ipsButton_important ipsButton_fullWidth" href="{$category->url()->setQueryString( array( 'do' => 'form', 'd' => \IPS\cms\Databases\Dispatcher::i()->databaseId ) )}">{lang="cms_add_new_record_button" sprintf="\IPS\cms\Databases::load( $category->database_id )->recordWord( 1 )"}</a>
bradl Posted February 26, 2016 Author Posted February 26, 2016 I did try extracting the code from listing and article templates where the button shows, but if moved to a block it breaks the plugin (preview goes blank). I think there is additional context missing to allow the snippet to do its thing. Appreciate the idea though.
TAMAN Posted February 26, 2016 Posted February 26, 2016 i will test it when i get on my pc later and let know if i make it work
Meddysong Posted February 26, 2016 Posted February 26, 2016 3 hours ago, bradl said: I did try extracting the code from listing and article templates where the button shows, but if moved to a block it breaks the plugin (preview goes blank). I think there is additional context missing to allow the snippet to do its thing. I think it's that the code makes reference to variables tied to the database. When used within the proper database templates, it knows what the database and its properties are. But when you move it to a block, it no longer has that assigned variable from which to pull its information.
Recommended Posts
Archived
This topic is now archived and is closed to further replies.