Jump to content

Add an Add Record button in feed block


bradl

Recommended Posts

Posted

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?

Posted

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>

 

Posted

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>

 

Posted

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.

Posted
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.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...