Problems, need help? Have a tip or advice? Post it here.
11 posts Page 1 of 2
Hello all,

I went through the Relationships topic.

I used the many-to-one relation for my use-case.

What I could understand from the documentation is that when I select an album only then it gets displayed using the cms:related_pages tag or cms:reverse_related_tag on the front.

What I was wondering was, that is there a way to display the unselected relations on the front end?

My use case is, there are students and months (both dropdown relations) on a third template fees. I was wanting to achieve that for a student only the months for which she has not payed the fees should be displayed in the month dropdown. And once the fees for that month is paid, the month name should no longer be available.

Is this the right approach? Or should it be done in some other way?

Please advice.

Regards,
GenXCoders
Image
where innovation meets technology
You missed "advanced relations" documentation point -
See section 2. Enhanced cms:pages tag here viewtopic.php?f=5&t=8581
Join COUCH:TALK channel here https://t.me/couchcms_chat
Ryazania — a framework to boost productivity with Add-ons viewtopic.php?f=2&t=13475
Support my efforts to help the community https://boosty.to/trendo/donate
It can be done even simpler, with the use of this basic feature ("NOT id") - https://docs.couchcms.com/tags-reference/pages.html#id
Join COUCH:TALK channel here https://t.me/couchcms_chat
Ryazania — a framework to boost productivity with Add-ons viewtopic.php?f=2&t=13475
Support my efforts to help the community https://boosty.to/trendo/donate
@trendoman

Thanks a ton for the reply. But the resources only ended up confusing me more.

My use case is: Students pay monthly fees. This fees should be saved in backend with their name, month and amount, which can be queried later when required.

My Approach:
1. student.php template to register student. It is a DBF that saves the student details like name, mobile and email.
2. fees.php template used to input months and the fees amount. It is a DBF.
3. fees-payment.php template to have the students and months listed in dropdowns using relations (see code#1) along with a read-only text input with the months' fees amount in it. It is a DBF with 3 fields, viz. student, month, fees.

Code: Select all
Code #1
<cms:editable type='relation' name='feespay_student' label='Student Name' masterpage='students.php' order='1' />
<cms:editable type='relation' name='feespay_month' label='Month' masterpage='fees.php' order='2' />


I have been able to display the student and month list in the dropdown & the fees in the read-only text input and save it. Now the issue is that:
1. Can I alphabetically arrange the student names?
2. Have the Month names displayed from Jan to Dec (currently they are displayed Dec to Jan)
3. Most Importantly: Can it be possible with the above approach to:
a. display the months only when a student is selected (I have a code to do that by HTML and JS)
b. display only the months the student has not paid the fees for.

Should the approach be changed or be continued to achieve the task at hand? What do you suggest?

Regards,
GenXCoders
Image
where innovation meets technology
At first, I would eliminate code1 editables from fees-payment.php, because I don't see yet why it needs them. What I mean is a simplification - put a single relation from students.php to fees.php. So, when a student pays for 2 months - Oct2018 and Nov2018 - then those 2 cloned pages from fees.php (oct2018 and nov2018) will be related to that particular student. Will it make things easier?

1,2 answers are simple - use order='asc' parameter in cms:related_pages.
Join COUCH:TALK channel here https://t.me/couchcms_chat
Ryazania — a framework to boost productivity with Add-ons viewtopic.php?f=2&t=13475
Support my efforts to help the community https://boosty.to/trendo/donate
@trendoman,

At first, I would eliminate code1 editables from fees-payment.php, because I don't see yet why it needs them. What I mean is a simplification - put a single relation from students.php to fees.php. So, when a student pays for 2 months - Oct2018 and Nov2018 - then those 2 cloned pages from fees.php (oct2018 and nov2018) will be related to that particular student. Will it make things easier?


Actually the fees needs to be collected from the third template, say 'fees-payment.php'. In the 'fees-payment.php', a DBF, there are 3 components, viz.:
1. Dropdown #1, Student list (pre populated)
2. Dropdown #2, Month list (pre populated)
3. Textbox, displays the fees corresponding to the month selected in #2.

Now this is required so that during fees collection the fees collector does not have to worry about the fees amount. They will be saved already and populate the Dropdown #2.

Do you suggest something else?

1,2 answers are simple - use order='asc' parameter in cms:related_pages.

Since the relation is defined in the 'fees-payment.php' template, we can directly use:
Code: Select all
<cms:input name='feespay_student' type='bound />

and since it is a many-to-one relation it gets displayed as a dropdown. The same happens for the second dropdown of months.

Do you suggest something else?

I was looking forward to have a third template because the logged in user (fees collector) will be able to see only the fees collection page with the student list and month list. Nevertheless, once a student pays the fees for a particular month, that month should not be displayed in the month dropdown for the particular student.

Any inputs would be helpful.

Regards,
GenXCoders
Image
where innovation meets technology
Since the relation is defined in the 'fees-payment.php' template

If you use bound inputs, then put orderby and order to the relation editable definition.
Join COUCH:TALK channel here https://t.me/couchcms_chat
Ryazania — a framework to boost productivity with Add-ons viewtopic.php?f=2&t=13475
Support my efforts to help the community https://boosty.to/trendo/donate
@trendoman

I will do that in the meanwhile.

Any suggestions for the other thing?

Regards,
GenXCoders
Image
where innovation meets technology
Bound inputs can not be used to list only unpaid months.. Use regular inputs :)
Join COUCH:TALK channel here https://t.me/couchcms_chat
Ryazania — a framework to boost productivity with Add-ons viewtopic.php?f=2&t=13475
Support my efforts to help the community https://boosty.to/trendo/donate
@trendoman

As you suggested,
Bound inputs can not be used to list only unpaid months.. Use regular inputs :)

I have taken regular inputs as:

1. For Student:
Code: Select all
<select name='f_receipt_student' id='f_receipt_student'>
    <option selected disabled>Select Student</option>
    <cms:pages masterpage='students.php' order='asc'>
    <option value="<cms:show k_page_title />"><cms:show k_page_title /></option>
    </cms:pages>
</select>
<cms:hide><cms:input name='receipt_student' type='bound' /></cms:hide>


2. For Months:
Code: Select all
<select name='f_receipt_month' id='f_receipt_month' >
    <option selected disabled>Select Month</option>
    <cms:pages masterpage='fees.php' order='asc'>
    <option value="<cms:show k_page_title />" label="<cms:show fees />">
        <cms:show k_page_title />
    </option>
    </cms:pages>
</select>
<cms:hide><cms:input name='receipt_month' type='bound' /></cms:hide>


3. For Fees:
Code: Select all
<cms:input id="f_receipt_fees" name='receipt_fees' placeholder='fees' type='bound' readonly='1' />


I was trying to do as suggested in the post, viewtopic.php?f=2&t=10721#p27123, but nothing fruitful has come up.

So, how can I list only unpaid months in this?

Regards,
GenXCoders
Image
where innovation meets technology
11 posts Page 1 of 2
cron