Problems, need help? Have a tip or advice? Post it here.
18 posts Page 1 of 2
Hi All,

I have a section where members can submit a databound form. The content is then displayed in a list view of all thats been submitted in that template. Now when its listed i want to show the user who posted it. I also have some user custom fields that i wanted to share. Which is the profile_img and show the members title.

Code: Select all
<cms:pages masterpage='members/article.php' > 
<div id="page_profile_content8" style="margin-top:20px;">

<!---  Show user profile submit information --------->
<div id="user_imgsmall"><cms:show profile_img /></div>
<div style="width:870px; height:auto; padding:20px; background-color: #FFFFFF; float: left;" >
<div id="user_post"><strong><cms:show k_member_title /></strong> posted <cms:date k_page_date format='jS M, Y' /></div>



<!---  PLACE YOUR CONTENT HERE --------->
<div id="user_post_title"><cms:show art_title /></div>
<div id="user_post_content"><cms:show art_information /></div>
<div id="user_post_img"><cms:show art_img /></div>
</div>
</div>


</cms:pages>
I have a section where members can submit a databound form
Now when its listed i want to show the user who posted it.
So, Simon, are you saving this info (i.e. id or name of the logged-in member doing the posting) with the posted article?
Hi Kk,

That's a very good point. I've not show the details within the articles.php page. I'll try that!
KK wrote:
I have a section where members can submit a databound form
Now when its listed i want to show the user who posted it.
So, Simon, are you saving this info (i.e. id or name of the logged-in member doing the posting) with the posted article?


Hi KK,

I'm unsure if you mean within the article.php page or the article_sub.php databound form? heres my form code

Code: Select all
        <cms:set submit_success="<cms:get_flash 'submit_success' />" />
        <cms:if submit_success >
            <div class="alert alert-success"><strong>Success:</strong> Your consumption has been sent successfully.</div>
        </cms:if>
       

           
      <cms:form
            masterpage='members/article.php'
            mode='create'
            enctype='multipart/form-data'
            method='post'
            anchor='0'
            >
           
            <cms:if k_success >
           
                <cms:check_spam email=frm_email />
               
                <cms:db_persist_form
                    _invalidate_cache='0'
                    _auto_title='1'
                />
               
                <cms:if k_success >
                    <cms:set_flash name='submit_success' value='1' />
                    <cms:redirect k_page_link />
                </cms:if>
            </cms:if>
           
            <cms:if k_error >
                <div class="alert alert-danger"><strong>Error:</strong>
                    <cms:each k_error >
                        <br><cms:show item />
                    </cms:each>
                </div>
            </cms:if>
           
           
           
            <table border="0" cellspacing="10" cellpadding="5">
  <tr>
    <td width="910"><span class="style3"><strong>Article Title</strong></span></td>
  </tr>
  <tr>
    <td><cms:input name='art_title' type='bound' style=" padding:10px; width:400px; margin-bottom:10px; border:#CCCCCC 1px solid;" /></td>
  </tr>
  <tr>
    <td><span class="style3"><strong>Article Text</strong></span></td>
  </tr>
  <tr>
    <td><cms:input name='art_information' type='bound' style=" padding:10px; width:400px; margin-bottom:10px; border:#CCCCCC 1px solid;" /></td>
  </tr>
  <tr>
    <td><span class="style3"><strong>Article image</strong></span></td>
  </tr>
  <tr>
    <td><cms:input name='art_img' type='bound' style=" padding:10px; width:400px; margin-bottom:10px; border:#CCCCCC 1px solid;"  trust_mode='1'/></td>
  </tr>
</table>

</div>




<div id="page_profile_content1"><cms:if "<cms:not submit_success />" >
                <button class="btn btn-primary" type="submit">Submit Application</button>
            </cms:if>
           
      </cms:form>

</div></div>
<cms:else />


Thank you KK for all your support so far 8-)
Your DataBound Form is creating cloned pages of template 'members/article.php'.
So in that template (i.e. members/article.php) define a region as follows -
Code: Select all
<cms:editable name='author' type='text' search_type='integer' />

Now in the form, add this to the cms:db_persist_form tag
<cms:db_persist_form
_invalidate_cache='0'
_auto_title='1'
author=k_member_id
/>

As you can see, we are saving the currently logged-in member's ID in the 'author' field (I trust you have enforced that only logged-in members can access this form).

So every article will have its author's ID too.
Given an author's ID, we can now use cms:pages to fetch the author's info (i.e. cloned page representing the author from the member template).

Clear?
KK wrote: Your DataBound Form is creating cloned pages of template 'members/article.php'.
So in that template (i.e. members/article.php) define a region as follows -
Code: Select all
<cms:editable name='author' type='text' search_type='integer' />

Now in the form, add this to the cms:db_persist_form tag
<cms:db_persist_form
_invalidate_cache='0'
_auto_title='1'
author=k_member_id
/>

As you can see, we are saving the currently logged-in member's ID in the 'author' field (I trust you have enforced that only logged-in members can access this form).

So every article will have its author's ID too.
Given an author's ID, we can now use cms:pages to fetch the author's info (i.e. cloned page representing the author from the member template).

Clear?


Hi KK,

I understand the concept now. I'm sorry to of been a pain.

Thank you very much for your help and support
Hey, you are always welcome Simon :)
Adding to the solution - following is how you'd list all the pages posted by a logged-in member
Code: Select all
<cms:if k_member_logged_in >
    <cms:pages masterpage='members/article.php' custom_field="author==<cms:show k_member_id />">
        ...
    </cms:pages>
</cms:if>
Thank you kk. This worked great!

Is it possible to still list like this if the members logged out? I'm
Using the index.php page which is the members clone page. Which allows none-registered members to view others profile.
If you mean the posted articles, you can always list them the usual way like this -
Code: Select all
<cms:pages masterpage='members/article.php'>
   ...
</cms:pages>
The code above doesn't care whether a member is logged-in or not.
18 posts Page 1 of 2