Hi, this thread is mainly for pick up some advices for the development.
As in title, I want to give the user the possibility of download files but they have to fill a 2 field form (name/email).
What's the problem?
The form is placed in some article (using chronoform plugin) and each article has its file.
Make a new form for each article is against the IT principles😀
How do you think can I do that?
As in title, I want to give the user the possibility of download files but they have to fill a 2 field form (name/email).
What's the problem?
The form is placed in some article (using chronoform plugin) and each article has its file.
Make a new form for each article is against the IT principles😀
How do you think can I do that?
Hi alfredopacino,
Please see this FAQ that should let you get the current article id or title and then you can use that to look up the matching file and build a link to it.
Bob
Please see this FAQ that should let you get the current article id or title and then you can use that to look up the matching file and build a link to it.
Bob
are you suggesting something like
or something different (or better)?😉
$id = JRequest::getInt('id', '');
switch($id){
case 10:
$url="/file.zip";
break;
case 111:
$url="/file.zip";
break;}
or something different (or better)?😉
Hi alfredopacino,
A switch will work fine but is a bit hard to update if anything changes. I'd probably use something like this:
Or you could save the file info in a database table and look it up from there. That works better if there are frequent changes as you can build a CC List and a CC Form to manage the list.
Bob
A switch will work fine but is a bit hard to update if anything changes. I'd probably use something like this:
<?php
$files_array = array(
10 => 'file_a.zip',
111 => 'file_b.zip',
. . .
);
$form->data['form'] = '';
if ( isset($form->data['id']) && intval($form->data['id']) > 0 && array_key_exists($form->data['id'], $forms_array) {
$form->data['form'] = JURI::root().'some_path/'.$forms_array[$form->data['id']];
}
?>
Then if you add an article you only need to add a new array entry,
Or you could save the file info in a database table and look it up from there. That works better if there are frequent changes as you can build a CC List and a CC Form to manage the list.
Bob
I've not tried yet, but what's $form->data['id'] ?
I need the article id, is that it?
I need the article id, is that it?
This topic is locked and no more replies can be posted.