Gossamer
Active member
Hello! So, I'm tackling another modification for my forum. I followed the tutorial on reading and writing to the database here, and it was very helpful. I've modified the end result a bit to include two fields that end up getting compiled into a list. I also removed the page element and instead used a new route prefix to create the main page for this modification.
The tutorial has it setup so that the "write" is on one tab and the "read" is on a second tab. I'm trying to get the contents of both to display in one view without the tabs. Unfortunately, I haven't figured out how to do so and still keep the functionality of the "read" tab, which is passed via a link.
What's a method to pull in functionality into a template? So far, I've only done it through page callbacks or template hooks and I'm having trouble finding an alternative to those.
Here is my ControllerPublic file:
And this is how the "read" view is currently pulled in through a template:
Any help would be greatly appreciated. I can show the rest of my code too if necessary.
The tutorial has it setup so that the "write" is on one tab and the "read" is on a second tab. I'm trying to get the contents of both to display in one view without the tabs. Unfortunately, I haven't figured out how to do so and still keep the functionality of the "read" tab, which is passed via a link.
What's a method to pull in functionality into a template? So far, I've only done it through page callbacks or template hooks and I'm having trouble finding an alternative to those.
Here is my ControllerPublic file:
PHP:
<?php
class goss_Reservations_ControllerPublic_Reserves extends XenForo_ControllerPublic_Abstract
{
public function actionIndex()
{
return $this->responseView('Reservations_ViewPublic_Reserves', 'goss_reserves');
}
/**
* Write to the database the text that the user wrote in the textbox.
*/
public function actionWrite()
{
//Get the text that user wrote in the text box
/* $Character = $this->_input->filterSingle('Character', XenForo_Input::STRING); */
$Reserve = $this->_input->filter(array(
'Character' => XenForo_Input::STRING,
'Fandom' => XenForo_Input::STRING));
//Create a instance of our DataWriter
$dwReserve = XenForo_DataWriter::create('Goss_Reservations_DataWriter_Reserves');
//Set the field with the data we filtered
$dwReserve->bulkSet($Reserve);
//Save in the database, please!
$dwReserve->save();
//Send a response to the user, so he know that everything went fine with this action
return $this->responseRedirect(
XenForo_ControllerResponse_Redirect::SUCCESS,
$this->getDynamicRedirect()
);
}
/**
* Get all the saved text in our table.
*/
public function actionRead()
{
//Get all rows from our table and set it to a variable
$viewParams = array('Reserves' => $this->_getReserveModel()->getAllReserves());
//Send a response view, using a template, to show all the data that we get it.
return $this->responseView('XenForo_ViewPublic_Base', 'goss_reserves_list', $viewParams);
}
/**
* Get the simple text model.
*
* @return SimpleText_Model_SimpleText
*/
protected function _getReserveModel()
{
return $this->getModelFromCache ( 'Goss_Reservations_Model_Reserves' );
}
}
And this is how the "read" view is currently pulled in through a template:
PHP:
<li id="read" class="profileContent" data-loadUrl="{xen:link reserves/read}">
<span class="jsOnly">{xen:phrase loading}...</span>
</li>
Any help would be greatly appreciated. I can show the rest of my code too if necessary.