solved Modify the guestbook module or build a custom module?

alt=
@hello77957
5 years ago
56 posts
Hi I want to add a section to users profiles whereby other users post testimonials about the experience of working with profile owner.

I thought I might be able to tweak the guestbook module for this purpose, but because it works differently to other modules, I can't find a way to:
1. add fields to the form (I want one select option where the poster selects their connection to the profile owner)
2. make it so that everyone can view the posts but only logged in users can make a post.

Is it going to be possible to adapt the module in this way? or would it be better to try and make a custom module for this function?
updated by @hello77957: 04/20/19 01:26:53PM
michael
@michael
5 years ago
7,692 posts
Better to make your own custom module. They're not that difficult to build and all follow the same basic structure, so once you know how to build a simple one like your thinking about you'll see that you can build any other one fairly easily.

You'll need:
* an index.php file to hold your create and update views
* an include.php file to hold your modules _init() function
* a schema.php file to initiate the datastore

Then depending on where you want the output to come out, maybe
* a /templates/item_index.tpl (to show a list of them on a profile index)
* a /templates/item_list.tpl (to show what they look like when called in a list by jrCore_list )
* a /templates/item_detail.tpl (to show them individually on their own page.)
alt=
@hello77957
5 years ago
56 posts
Thanks Michael, I shall give it a go :)
michael
@michael
5 years ago
7,692 posts
:thumbs-up:

Hit us with specific questions where you get stuck. Open a thread for each question, let us solve it and open another thread for the next problem.

Mammoth threads never get read and quickly get confusing. :)

Start by setting up the module structure with an include.php file, then try to turn your module on in the ACP.

Look at the other modules as a guide.

--edit--
ah, and turn on developer mode so you dont get caching issues
ACP -> TOOLS -> DEVELOPER TOOLS -> GLOBAL CONFIG -> RUN IN DEVELOPER MODE
updated by @michael: 01/15/19 07:52:18PM
alt=
@hello77957
5 years ago
56 posts
Hah! Yes, I've got as far as getting it in the ACP, now trying to figure out quota configs :)
paul
@paul
5 years ago
4,325 posts
As it sounds as through you just want a variant of the Guestbook module, maybe 'clone' that and use that as a starting point?
Try it as follows -

1) Create your module folder 'xxTestimonial' say
2) Copy all the jrGuestBook files to xxTestimonial
3) Work through all xxTestimonial files changing all instances of 'jrGuestBook' to 'xxTestimonial' and 'guestbook' to 'testimonial'
4) Test the new xxTestimonial to see that it still works the same as the guestbook module
5) Edit the xxTestimonial item_index.tpl template to add extra fields to the 'sign' page
6) As admin, goto a user's testimonial page and click on the update (*) icon. Use the Form Designer to add form fields to match those added to the template.

Quote: make it so that everyone can view the posts but only logged in users can make a post.
The GuestBook module already works this way so nothing to do for that.

Hope this helps


--
Paul Asher - JR Developer and System Import Specialist
alt=
@hello77957
5 years ago
56 posts
Hi Paul, I did try making a clone but I came up against some issues I couldn't figure out:

Because it's designed for other users to post on a users profile rather than for the profile owner to enter info, the guestbook doesn't have a form for the profile owner in the way that other modules have (there's no 'create new' on the admin side) so form designer doesn't appear. I would need to hard code the extra form fields and i'm still trying to figure out how to get those fields configured.

Also, the logged into post - I explained that wrong, what I actually want is:
I have three quotas - A,B,C
Only quota A has testimonials on their profiles
Only quotas A, and B can post testimonials on other (quota A's) profiles
Anyone, logged in or out, can view the testimonials on a quota A's profile

Does that make sense? or have I confused myself?
updated by @hello77957: 01/16/19 05:51:11AM
alt=
@hello77957
5 years ago
56 posts
paul:
6) As admin, goto a user's testimonial page and click on the update (*) icon. Use the Form Designer to add form fields to match those added to the template.
Oh, hang on, I think I understand what you mean now, I need to make a user profile (not my own admin one) and work as if i was making an entry on their profile?

Edit: No, there's still no update function
updated by @hello77957: 01/16/19 06:01:50AM
paul
@paul
5 years ago
4,325 posts
Quote: Because it's designed for other users to post on a users profile rather than for the profile owner to enter info, the guestbook doesn't have a form for the profile owner in the way that other modules have (there's no 'create new' on the admin side) so form designer doesn't appear. I would need to hard code the extra form fields and i'm still trying to figure out how to get those fields configured.

Yes, the GuestBook module is a bit different, as you say, because users other than the profile owner can create entries. This is why there is no 'jrGuestBook_create' view in the module's index.php file and the form is included in the module's 'item_index.tpl' template file (lines 19 - 39) -
        <div class="item">

            {if jrUser_is_logged_in()}

                <div id="guestbook_notice" style="display:none;"><!-- any guestbook errors load here --></div>

                <form id="gform" method="POST" onsubmit="jrGuestBook_post_entry('{$_profile_id}','#gform','#guestbooks');return false">
                <input type="hidden" id="profile_id" name="profile_id" value="{$_profile_id}">
                <textarea name="guestbook_text" cols="40" rows="5" class="form_textarea"></textarea>
                <br>
                <div style="vertical-align:middle">
                    <img id="form_submit_indicator" src="{$jamroom_url}/skins/{$_conf.jrCore_active_skin}/img/submit.gif" width="24" height="24" alt="{jrCore_lang module="jrCore" id="73" default="working..."}" style="margin:8px 8px 0px 8px;"><input id="guestbook_submit" type="submit" value="{jrCore_lang module="jrGuestBook" id="19" default="sign guest book"}" class="form_button" style="margin-top:8px;">
                </div>
                </form>

            {else}

                {jrCore_lang module="jrGuestBook" id="22" default="You must be logged in to post to this guestbook!"}

            {/if}
        </div>

Quote: Also, the logged into post - I explained that wrong, what I actually want is:
I have three quotas - A,B,C
Only quota A has the module on their profiles
Only quotas A, and B can post to the modules on other (quota A's) profiles
Anyone, logged in or out, can view entries on a quota A's profile

Do this by adding extra conditions to the if statement in the above template code -

{if jrUser_is_logged_in() && ($_user.profile_quota_id == A || $_user.profile_quota_id == B)}

A and B would need to be the numeric values of the quota_id's in question, of course.

You then might want to modify the view_jrGuestBook_sign function in the module index.php as an extra security feature -

    // Must be logged in
    jrUser_session_require_login();
    if ($_user['profile_quota_id'] != A && $_user['profile_quota_id'] != B) {
        jrUser_not_authorized();
    }
    jrCore_validate_location_url();

with A and B being the numeric quota_ids, as above.

hth


--
Paul Asher - JR Developer and System Import Specialist
alt=
@hello77957
5 years ago
56 posts
Brilliant! got the form designer appearing now, just the quota config to do.

Thanks so much for the help!


Jamroom is a huge learning curve, but mainly because you have to learn how much simpler everything is than you expected it to be...once you get how it all works! :)
updated by @hello77957: 01/16/19 06:16:48AM

Tags