Page 1 of 1

Add PublishDate/UnpublishDate to Frontend Upload

Posted: 02 Dec 2014, 11:53
by spoint
Hello,
I'm trying to edit the Frontend-User File located in:
\components\com_phocadownload\views\user\tmpl\default_files.php
and the other File which i think it would to the Datebase-Save-Action located in:
\components\com_phocadownload\views\user\view.html.php

For me, I need the ability to add the Publish Date and Unpublish Date as 2 additional Fields in Frontend-Form for the Users.

I add the following lines in
default_files.php near line 270

Code: Select all

<tr>
<td><strong>Begin:</strong></td>
<td><input size="10" type="text" id="phocadownload-upload-publish_up" name="phocadownloaduploadpublishup" value="<?php echo $this->formdata->publish_up ?>" maxlength="10" /></td>
</tr>
		
<tr>
<td><strong>End:</strong></td>
<td><input size="10" type="text" id="phocadownload-upload-publish_down" name="phocadownloaduploadpublishdown" value="<?php echo $this->formdata->publish_down ?>" maxlength="10" /></td>
</tr>
wihtin the 2nd Form-Tag for the Upload-Action

Code: Select all

<form onsubmit="return OnUploadSubmitFile();" action="<?php echo $this->t['actionamp'] ?>task=upload&<?php echo $this->session->getName().'='.$this->session->getId(); ?>&<?php echo JSession::getFormToken();?>=1" name="phocadownloaduploadform" id="phocadownload-upload-form" method="post" enctype="multipart/form-data">
and add following lines in viewhtml.php
near Line 101:

Code: Select all

$formData->set('publish_up','');
$formData->set('publish_down','');
near Line 126:

Code: Select all

$post['publish_up']	= $app->input->get( 'phocadownloaduploadpublishup', '', 'string' );
$post['publish_down']	= $app->input->get( 'phocadownloaduploadpublishdown', '', 'string' );
near Line 136:

Code: Select all

if ($post['publish_up'] != '')		{$formData->set('publish_up', $post['publish_up']);}
if ($post['publish_down'] != '')	{$formData->set('publish_down', $post['publish_down']);}

Unfortunately the publish_up and the publish_down will be submitted correctly in form but not be changed in database table jos_phocadownload.
The field publish_up is filled with the upload-Date and the field puplish_down is empty (0000-00-00 00:00:00); Even when the Fields are filled with custom Dates

Where can I find the file which do the save action and which lines did i need to edit for this?
This would be really great, if you can help me :)

Spoint

Re: Add PublishDate/UnpublishDate to Frontend Upload

Posted: 03 Dec 2014, 19:25
by Jan
Hi, it is in MVC, which means, every view has own controller and model:

- so if you send the form in view, then
- the controller get the data - you can filter them and then you send them
- to the model and there you can write the data into database:

components/com_phocadownload/controllers/user.php
components/com_phocadownload/models/user.php

see the save/store methods, etc.

Jan

Re: Add PublishDate/UnpublishDate to Frontend Upload

Posted: 04 Dec 2014, 01:50
by spoint
I edited the line 450 in components\com_phocadownload\models\user.php
from

Code: Select all

$row->publish_up = $now;
$row->publish_down = null;
to

Code: Select all

$row->publish_up = $data['publish_up'];
$row->publish_down = $data['publish_down'];
and it Works! :)
Many Thanks.
Thread can be close ;)

Re: Add PublishDate/UnpublishDate to Frontend Upload

Posted: 07 Dec 2014, 15:44
by Jan
Hi, great to hear it.
Thank you for the info.
Jan