×

Notice

The forum is in read only mode.
Welcome, Guest
Username: Password: Remember me
  • Page:
  • 1

TOPIC: How to customise the code ?

How to customise the code ? 15 years 5 months ago #4453

  • naveen
  • naveen's Avatar Topic Author
  • Offline
  • Fresh Boarder
  • Fresh Boarder
  • Posts: 4
  • Thank you received: 0
Hii Developer,

Thanks for the useful component. The component is working fine with extensive features and settings.

I have tried to customise the code as per my requirement. I have to add a selection box beside the name of the post entry form so as to define the role of the commenter. For, i need to add certain fields in the existing database table and do query operations. I have found some blocks in html code as {some} {/some} which i could not understand and to modify it further.

can you please help me in this regard to track the unknown blocks in template html page.


Thanks in advance

How to customise the code ? 15 years 5 months ago #4456

  • Daniel Dimitrov
  • Daniel Dimitrov's Avatar
  • Away
  • Administrator
  • Administrator
  • Posts: 9618
  • Karma: 155
  • Thank you received: 1081
Make new blocks. {test}{/ test}

then open comment.class.php and find the function visual_htmlCode()
you will see code like this
$html = JOSC_utils::checkBlock('ads', false, $html, $this->insertAds());
add
$html = JOSC_utils::checkBlock('test', false, $html, $this->mytestFunction());
 

In your test function you do what is necessary and ready :)

How to customise the code ? 15 years 5 months ago #4481

  • naveen
  • naveen's Avatar Topic Author
  • Offline
  • Fresh Boarder
  • Fresh Boarder
  • Posts: 4
  • Thank you received: 0
Hii Developer,

Thanks for the quick reply. I wish to add a new entity with the selection box which i have inserted in the following code comment.class.php as follows to appear in the html.

$html = str_replace('{_ENTERNAME}', _JOOMLACOMMENT_ENTERNAME, $html);
$html = str_replace('{username}', $this->_tname, $html);
$html = str_replace('{registered_readonly}', $this->readOnly($this->_tname), $html);
$html = str_replace('{userole}', '<select name="role" class="inputbox">
<option value="0">Student</option>
<option value="1">Alumni</option>
<option value="2">Faculty</option>
<option value="3">Other</option>
</select>', $html);


But, when i tried to get the posted value of name= role as $_POST["role"], i dint get the posted value. Not only this but also all the values in the form could not get the by $_POST variable.

Please do the help in this regard in getting the value in this way.

How to customise the code ? 15 years 5 months ago #4515

  • Daniel Dimitrov
  • Daniel Dimitrov's Avatar
  • Away
  • Administrator
  • Administrator
  • Posts: 9618
  • Karma: 155
  • Thank you received: 1081
Sorry naveen!
The problem is coming from the fact that I understood your post wrong. I didn't know that you want to edit the form.

Check out the form_htmlCode function.

How to customise the code ? 15 years 5 months ago #4564

  • naveen
  • naveen's Avatar Topic Author
  • Offline
  • Fresh Boarder
  • Fresh Boarder
  • Posts: 4
  • Thank you received: 0
Hii Daniel,

I have edited the from in form_htmlCode funtion which is posting the values to the index.php(action='PHP_SELF') of the web site by the form method post. But, when i tried to access the posted variables from the form, i could not get any value.

Can you please suggest me how to get the posted variable manually from $_POST global variable so as to do custom data operations with it.

The following is the edited form(in bold) code in form_htmlCode function

$html = str_replace('{_ENTERNAME}', _JOOMLACOMMENT_ENTERNAME, $html);
$html = str_replace('{username}', $this->_tname, $html);
$html = str_replace('{registered_readonly}', $this->readOnly($this->_tname), $html);
$html = str_replace('{userole}', '<select name="role" class="inputbox">
<option value="0">Student</option>
<option value="1">Alumni</option>
<option value="2">Faculty</option>
<option value="3">Other</option>
</select>', $html);


Thank you

How to customise the code ? 15 years 5 months ago #4566

  • Daniel Dimitrov
  • Daniel Dimitrov's Avatar
  • Away
  • Administrator
  • Administrator
  • Posts: 9618
  • Karma: 155
  • Thank you received: 1081
Hi naveen,
I have never said that you can access the post variable in the form_htmlCode :)

does your str_replace work? Do you get your select field?

Look for your post values in the execute or the insertNewPost function. Hope this helps.

How to customise the code ? 15 years 4 months ago #4700

  • naveen
  • naveen's Avatar Topic Author
  • Offline
  • Fresh Boarder
  • Fresh Boarder
  • Posts: 4
  • Thank you received: 0
Hii Daniel,

I have tried to add a simple input tag to the form as Role after Name, for, i have made the following changes in the code.

in template index.html in line 195:

<tr class='sectiontableentry1'>

<td><div class='item'>Role</div></td>

<td><div class='item'>

<input name='trole' type='text' class='inputbox' size='20' />

</div></td>

</tr>


and, the changed as following in comment.class.php
in decodeURI() function
$this->_trole = $this->decodeData_Charset('trole');

in class JOSC_board extends JOSC_visual :

var $_trole;

in insertNewPost($ajax = false) function

$role = $this->censorText(JOSC_utils::mysql_escape_string(strip_tags($this->_trole)));

inserted quest as:
$database->SetQuery("

INSERT INTO jos_comment

(contentid,component,ip,userid,usertype,date,name,userole,email,website,notify,title,comment,published,voting_yes,voting_no,parentid)

VALUES(

'$this->_content_id',

'$com',

'$ip',

'$userid',

'',

now(),

'$name',
'$role',

'$email',

'$website',

'$notify',

'$title',

'$comment',

'$published',

'0',

'0',

'$parent_id'

)");

having made all the changes above did not worked out for me in inserting the record field userole in the database which i have found NULL.

I have studied the code and had many trails to workout, but got no result. Can you please suggest me in how and where to make the changes in the code so as to add a customised filed in the feedback form.

Thank you

How to customise the code ? 15 years 4 months ago #4743

  • Daniel Dimitrov
  • Daniel Dimitrov's Avatar
  • Away
  • Administrator
  • Administrator
  • Posts: 9618
  • Karma: 155
  • Thank you received: 1081
Hey naveen,
Sorry for the delay! In matter of fact customizing the code is not so easy :)

As you have surely noticed - we use ajax. This means that we make asynchronous requests to the server. We have to send the code to the server using javascript.
Please look at the client.js file and specially the editPost function
if (JOSC_ajaxEnabled)
    {
        var param = new JOSC_HTTPParam();
        param.create(id == -1 ? 'ajax_insert' : 'ajax_edit', id);
        param.insert('content_id', form.content_id.value);
        if (JOSC_captchaEnabled) 
        {
            param.insert('security_try', form.security_try.value);
            param.insert('security_refid', form.security_refid.value);
        }
        if (parentid != -1) param.insert('parent_id', parentid);
        param.encode('tname', form.tname.value);
	    /* optional */
        if (document.getElementsByName('tnotify')[0])  { if (form.tnotify.selectedIndex) param.encode('tnotify', '1'); else param.encode('tnotify', '0'); };
        if (document.getElementsByName('temail')[0])    param.encode('temail', form.temail.value);
        if (document.getElementsByName('twebsite')[0])  param.encode('twebsite', form.twebsite.value);
        /************/
        param.encode('ttitle', form.ttitle.value);
	JOSC_ajaxSend(param.encode('tcomment', form.tcomment.value), JOSC_editPostResponse);
    } 

here you will have to provide your form element title too, so it can be actually send to the comment.class.php file.

Hope this helps :)
  • Page:
  • 1
Time to create page: 0.127 seconds