Keyword

One attachment folder per item

More
10 years 6 months ago #126882 by Lenny
One attachment folder per item was created by Lenny
Hello,

I'm looking to override the administrator/components/com_k2/models/item.php file to add a specific attachement directory per item (having everything in the same directory is not right for what I'm doing).

I think I should modify these lines (1107-1116) :

$path = $params->get('attachmentsFolder', NULL);
if (is_null($path))
{
$savepath = JPATH_ROOT.DS.'media'.DS.'k2'.DS.'attachments';
}
else
{
$savepath = $path;
}
$file = $savepath.DS.$attachment->filename;

But I failed whatever I have added at the end of $path or $savepath declaration...

Do you have an idea to achieve this ?

Thanks a lot

Please Log in or Create an account to join the conversation.

More
10 years 6 months ago #126883 by Lefteris
Replied by Lefteris on topic Re: One attachment folder per item
Hi. This is not that simple. You also need to modify the function that downloads the attachment. It's in the same file. The function is named "download".

JoomlaWorks Support Team
---
Please search the forum before posting a new topic :)

Please Log in or Create an account to join the conversation.

More
10 years 6 months ago #126884 by Lenny
Replied by Lenny on topic Re: One attachment folder per item
Thanks, I will try again and I'll post results.

Please Log in or Create an account to join the conversation.

More
10 years 5 months ago - 10 years 5 months ago #126885 by Lenny
Replied by Lenny on topic Re: One attachment folder per item
Hello,

since I am in the backend, will
$id = JRequest::getInt('id');

return the item id correctly ?

I am planning to append it to savepath, such as :
$savepath = JPATH_ROOT.DS.'media'.DS.'k2'.DS.'storage'.DS.$id;

in the third occurences found in the item.php file.

Thanks a lot.

Please Log in or Create an account to join the conversation.

More
10 years 5 months ago #126886 by Lefteris
Replied by Lefteris on topic Re: One attachment folder per item
Yes, on the save function you can get the ID like that. But this will not work for new items, which don't have an ID yet. I suggest that you use the variable:
$row->id

This is populated with the item ID after the item has been changed.

JoomlaWorks Support Team
---
Please search the forum before posting a new topic :)

Please Log in or Create an account to join the conversation.

More
10 years 5 months ago #126887 by Lenny
Replied by Lenny on topic Re: One attachment folder per item
Works like a charm :-)

Thanks a lot !

Please Log in or Create an account to join the conversation.

More
10 years 5 months ago #126888 by Lefteris
Replied by Lefteris on topic Re: One attachment folder per item
You are welcome.

JoomlaWorks Support Team
---
Please search the forum before posting a new topic :)

Please Log in or Create an account to join the conversation.


Powered by Kunena Forum