Invision Community 4: SEO, prepare for v5 and dormant account notifications Matt November 11, 2024Nov 11
Posted February 25, 20168 yr 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?
February 26, 20168 yr Author 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>
February 26, 20168 yr 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>
February 26, 20168 yr Author 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.
February 26, 20168 yr 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.
Archived
This topic is now archived and is closed to further replies.