Invision Community 4: SEO, prepare for v5 and dormant account notifications By Matt Monday at 02:04 PM
Meddysong Posted November 18, 2016 Posted November 18, 2016 I'm customising my templates to a particular database and one of the things I want to do is make it possible to add a new record. Normally that's part of the template, but the catch here is that I want my button to add a record in another category. In fact, I'm placing it in the categoryIndex. OK, I could just insert a button and give it an href to the category in question, but I'd also like to respect permissions to do so. The normal way of accomplishing this is: {{if $category->can('add')}} <li class='ipsToolList_primaryAction'> <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> </li> {{endif}} But $category refers to the current category, which is no good for me here. I presume I need to create a new variable myCat and then change references of $category to $myCat. I'd specifically like to target category_id = 94 of database_id = 30. Where I'm stuck is knowing how to write the variable such that it knows that it refers to category 94. How would i do this? ****** User case: I have a database of pronunciation recordings for my language learners. Nearly all of the categories are the letters of the alphabet into which recordings are placed. But one of the categories is for requests. What I'm doing is adding a button to my category index so that users can make a request on the first page rather than have to navigate to the requests category and then find the button. I know I could just add <li class='ipsToolList_primaryAction'> <a class="ipsButton ipsButton_medium ipsButton_important ipsButton_large" href="{setting='base_url'}pronunciation/requests/?do=form&d=30">{lang="new_lang_string_just_for_this"}</a> </li> but I'd like to respect permissions too. (To be honest, this doesn't really matter since everybody, including guests, has permission to add a record but it's the principle. I want to learn rather than find a particular work-around!)
Recommended Posts
Archived
This topic is now archived and is closed to further replies.