Support

  1. dlh
  2. Features Request
  3. Wednesday, March 11 2020, 07:06 PM
Hi there,
I would like to define automatically the title of a photo album by entering the category and a date field. For instance, there would be a category selection field and a date selection field.
If I put the category "Paris" and if I choose the date "11/07/2020", the title of the album will be "Paris 11/07/2020".
I tried something in the /plugins/jsn/socialnetwork/app/View/Albums/ajax_create.ctp file :
It works a little bit but instead of the title of the category (so in my example "Paris";), it put the ID of the category. Moreover, the date is in the YYYY-MM-DD format and I would like to have it in the dd/mm/yyyy format. Also, is it possible to had a character beatween the two variables, as a simple " - " to set the title of the album as "Paris - 11/07/2020".

Thanks so much in advance for your help !
Kind regards,
Yann
dlh Accepted Answer
Here is the code of my file /plugins/jsn/socialnetwork/app/View/Albums/ajax_create.ctp :
  1. more than a month ago
  2. Features Request
  3. # 1
dlh Accepted Answer
<li><label><?php echo __('Lieu')?></label>
<?php echo $this->Form->select( 'category_id', $categories, array( 'value' => $album['Album']['category_id'] ) ); ?>
</li>
<li><label><?php echo __('Jour')?></label>
<?php echo $this->Form->date( 'jour', array( 'value' => $topic['Album']['jour'])); ?>
</li>
  1. more than a month ago
  2. Features Request
  3. # 2
dlh Accepted Answer
At the end :

jQuery(document).ready(function($){
$('#title').closest('li').hide(); // Hide Title field
$('#category_id,#jour').change(function(){
$('#title').val($('#category_id').val() + ' ' + $('#jour').val() );
});
});
  1. more than a month ago
  2. Features Request
  3. # 3
admin Accepted Answer
Admin
Hi,
sorry for late reply, so you have solved?
  1. more than a month ago
  2. Features Request
  3. # 4
dlh Accepted Answer
Content Protected
  1. more than a month ago
  2. Features Request
  3. # 5
admin Accepted Answer
Admin
Hi,
to get something like this try with this code:
jQuery(document).ready(function($){
$('#title').closest('li').hide(); // Hide Title field
$('#category_id,#jour').change(function(){
var category = $('#category_id option:selected').text();
var jour = $('#jour').val();
var title = category + ' - ' + jour.substr(8, 2) + '/' + jour.substr(5, 2) + '/' + jour.substr(0, 4);
$('#title').val(title);
});
});
  1. more than a month ago
  2. Features Request
  3. # 6
dlh Accepted Answer
Hey there,
The solution your gave me the last time works perfectly.
However, I just have one more request. I would like to know if it's possible instead of the date field to put a select field to choose between "spotting by date" and "spotting by month".
If the user sets "spotting by date", it will display a date field to create an album name as, for instance, "Paris - 11/04/2020".
But if the user sets "spotting by month", it will display a month field to create an album name as, for example, "Paris - 04/2020".
Thanks in advance for your help !
Kind regards,
Yann
  1. more than a month ago
  2. Features Request
  3. # 7
admin Accepted Answer
Admin
Hi,
sorry for late reply, this is possible,
1) first you need to create a select with 2 options: "spotting by date" and "spotting by month":
- in file /plugins/jsn/socialnetwork/app/View/Albums/ajax_create.ctp add following code:
<li><label><?php echo __('Spotting Type')?></label>
<?php echo $this->Form->select( 'spotting_type', array('date'=>'Spotting by Date','month'=>'Spotting by Month'), array( 'value' => $album['Album']['category_id'] ) ); ?>
</li>

2) adapt the Javascript code to calculate the field title based also on field spotting_type
jQuery(document).ready(function($){
$('#title').closest('li').hide(); // Hide Title field
$('#category_id,#jour,#spotting_type').change(function(){
var category = $('#category_id option:selected').text();
var jour = $('#jour').val();
var title = category + ' - ' + jour.substr(8, 2) + '/' + jour.substr(5, 2) + '/' + jour.substr(0, 4);
if($("#spotting_type").val()=="month") title = category + ' - ' + jour.substr(5, 2) + '/' + jour.substr(0, 4);
$('#title').val(title);
});
});
  1. more than a month ago
  2. Features Request
  3. # 8
dlh Accepted Answer
Hi,
Thanks very much for your answer.
It works well! However I have another request: with this system, even if I choose by month, I have to select a day in the date field. Is there a solution which can help me to only display a month/year selector file if the user select this spotting type?
Thanks,
Kind regards,
Yann
  1. more than a month ago
  2. Features Request
  3. # 9
admin Accepted Answer
Admin
Hi,
sorry but this is not possible with a simple way:(
  1. more than a month ago
  2. Features Request
  3. # 10
dlh Accepted Answer
Hi there,
I worked a little bit on it and I found something interesting.
  1. more than a month ago
  2. Features Request
  3. # 11
dlh Accepted Answer
Content Protected
  1. more than a month ago
  2. Features Request
  3. # 12
admin Accepted Answer
Admin
Hi,
unfortunately in your HTML code there are 2 problems:
1) the field with name "jour" is declared 2 times, so when you submit the form the browser keep the value only of the first "jour" field
2) in the javascript function you switch the title from the value of the field called "spotting_type", but this field does not exist in your HTML code
  1. more than a month ago
  2. Features Request
  3. # 13
dlh Accepted Answer
Content Protected
  1. more than a month ago
  2. Features Request
  3. # 14
dlh Accepted Answer
Any update ?
  1. more than a month ago
  2. Features Request
  3. # 15
admin Accepted Answer
Admin
Hi,
sorry I does not understand where is the problem.

I have already provided you a code that do this (here) and you had confirmed that it works (here)

Now I see that you have write another code that can't never works (here) and I have explained you the reason (here).
  1. more than a month ago
  2. Features Request
  3. # 16
dlh Accepted Answer
Hey,
Thanks for your answer.
Yeah I understood that it can’t works like this because they are two problems but is there maybe a solution to these two problems ? I have some knowledges in HTML and php but not in JavaScript ? Is there maybe something to solve these problems with a code?
Sorry for my insistence but as I told you, I’m not very good at JavaScript so I don’t exactly know what is possible with this language.
Thanks in advance for your understanding and your answer.
Best regards,
Yann
  1. more than a month ago
  2. Features Request
  3. # 17
dlh Accepted Answer
Hey, any update?
  1. more than a month ago
  2. Features Request
  3. # 18
admin Accepted Answer
Admin
Hi,
sorry but we cannot do this for you because as we told you there is not a simple way (something like this requires about 2 hours of work), we can only point you on the right direction.
  1. more than a month ago
  2. Features Request
  3. # 19
  • Page :
  • 1


There are no replies made for this post yet.
However, you are not allowed to reply to this post.

Request Support

Support is currently Offline

Support Availability

Working days: Monday to Friday. The support staff is not available on weekends; in the most of cases tickets will not be answered during that time.

Reply time: Depending on the complexity of your support issue it's usually between a few minutes and 24 hours for paid members and about one week for free members. When we expect longer delays we will notify you.

Guidelines

Before you post: read the documentation and search the forums for an answer to your question.

When you post: include Site Details if you request a support (you can use the form below the reply in Site Details tab).

Auto Solved Question: If after a week the author of the post does not reply to a request by moderator, the question will be marked as resolved.

Language: only English

Search Users

Easy Profile® is not affiliated with or endorsed by Open Source Matters or the Joomla Project. Joomla is Free Software released under the GNU/GPL License.