Author Topic: Beginners guide. how to make a plugin. plugins google_ad_locator & search_by_zip  (Read 3203 times)


  • Guest
Hy all.. y guess the better title  is begginer try to make a plugin... but we will see on the road..
so ive decided  to try   making a new plugin. google_ads_locator to display ads on gmap...
since  im a  hobby developer.. the road  will be long and hard :)
 yll explain my steps.. and hope that can be followed by others to develop new  plugins  easier  :)

 the 2 scripts that y use work for separate  y will try to combine them and implement into osclass

let start with the final look...see picture
the first one 1... search_by_zip.. we have 2 options
                                                                   to change from neibourhood to zip on item_detail.
                                                                  or implement new item field zip_code
and can be used for a plugin by himself.. search_by_zip plugin.. we will see  if is usefull

second one 2 google_ad_locator displays all ads from a range selected by  user inserting zip code....
 this is for one country osclass  install ...

any help & ideas  is welcome :).
wish me luck.. and see u soon with the steps y folow
« Last Edit: November 16, 2012, 01:51:56 am by lucky_strike »


  • Guest
:) first one ready folowing step by step  this " tutorial " :
time to test it
yll be back with details


  • Guest
so...succesful installl  but y cannot configure.

 yve done something wrong :)
Edited.. missed 2 function names.. solved :)

   first steps .
   it should be 30minutes or more ... medium knowledges php

1. copy files from products_atribute folder into my_own_plugin_folder
   edit plugin details index.php
    Plugin Name & company
2.y ve started  editing with struct.sql
       change t_item_products_attr with your_own_table
           search and replace any reference of  t_item_products with your_own_table in any files inside the folder

                 since y need one field yve keeped s_make and transformed into s_my_field
       search and  replace any reference of S_make with s_my_field in   any files inside the folder
       delete any reference of s_model from the files with the block who mention it
           for example
              :newInstance()->insertAttr($item_id, Params::getParam('make'), Params::getParam('model'));


                   insertAttr($item_id, Params::getParam('s_my_field'))   ...
                       public function insertAttr( $item_id, $make, $model)
                                   public function insertAttr( $item_id, $Your_field_variable)
         and so on.....
3. declare  your class
     inside ModelProducts.php
         class ModelProducts extends DAO becomes : class ModelXXXXXXXX extends DAo
   rename the file
    ModelProducts.php becomes ModelXXXXXXXX.php (xxxxxxx =your chosen name)
  search and replace any reference of ModelProducts with ModelXXXXXXXX... in any file inside the folder
 change function name  getTable_ProductsAttr() into get_Table_your_function_name
search and replace any reference of the function with the new one

4 index.php
   replace function names with your functions ...
  after this line
   // This is needed in order to be able to activate the plugin
    follow the  oficial docs    :)   ...:
5. item_edit.php   ,item detail.php ,search_form.php

 if u cannot modify this files then you  should stop    and......

     go to  they have a good  html php and css tutorial  :))
             stop asking on forums  how to change button color . :)
 6.  put the plugin where he belongs. to test  it ...
 7 .installl
 8 .test it
« Last Edit: November 17, 2012, 05:28:59 pm by lucky_strike »


  • Guest
this is a prof of concept... it not that hard  to make a  plugin.. 1 hour to modify the existing one.
it works.... it really works .:)   test it  yourself..
   add just a simple zip_code field into item attributes
  please back_up your installation first .. im not responsable  for any data loss :)))
.. code inspection from ..  experienced developers needed..

 now step 2...

      to   add a radius search option
Y WILL BE BACK ! ! !  ;)

« Last Edit: November 16, 2012, 02:03:18 am by lucky_strike »


  • Guest
  next step we have to make the zip_code field  required on item posting.... 
       we have the option to edit the existing location_required plugin or make a new one.
          a new one is easier to  do it :)
              y dont (f.....) now how to overide the existing one :))
                  if anyone can help in this direction would  be better
                    we will  use that   if( !function_exists('metadata_js') ) { ...}
                       and create a new one
Code: [Select]
function zip_code_js() {
    <!-- requrire zip -->
    <script type="text/javascript">
        $(document).ready(function() {
        if( $("form[name=item]").length > 0 ) {
                $('input[id="zip_code"]').addClass("{required: true, messages: { required: '<?php _e("Zip code is required""name of _your _plugin _folder") ; ?>'}}") ;
        }) ;
    <!-- require zip_code end -->

  if im going in wrong direction please reply.....

 next step is   to start building the new  plugin..   google_ad_locator...

      for  that  we follow the steps above    rewriting the search by zip plugin extending the  database fields...
creating a new table.

Code: [Select]
CREATE TABLE /*TABLE_PREFIX*/t_item_gzip_attr (
    fk_i_item_id INT UNSIGNED NOT NULL,
    s_zip_code VARCHAR(7),
    fk_c_country_code CHAR(2) NOT NULL,
    city varchar(50) collate utf8_bin default NULL,
    county varchar(50) collate utf8_bin default NULL,
    state_name varchar(50) collate utf8_bin default NULL,
    state_prefix varchar(2) collate utf8_bin default NULL,
    area_code varchar(3) collate utf8_bin default NULL,
    time_zone varchar(50) collate utf8_bin default NULL,
    latitude DECIMAL(10,6),
    longitude float NOT NULL,
PRIMARY KEY (fk_i_item_id),
 INDEX s_zip_code (s_zip_code),
        FOREIGN KEY (fk_i_item_id) REFERENCES /*TABLE_PREFIX*/t_item (pk_i_id)

 can inlude more fields
   ip.. time... country... since this  is a prove of concept..   we have time  to    test and polish the plugin
 why so many? :)
    we may need them for other  stuffs
       ( this is the  hard way :))  we can find defined  s_zip in osclass before)
here is the scenario ...
 user insert location and zip
        (we could use adress or city but some times user prefer to be anonimus.... so zip code is the answer)
       osclass get user imput from fields...
        we will use another way
             from zipcode we will get adress  ,city,region latitude and longitude
             becouse : "formatted_address" : "35011 xxxxxxx
                                  "location" : {
                                                           "lat" : 28.12388130,
                                                           "lng" : -15.43902540

                              "formatted_address" : "35013
                                            "location" : {
                                                                "lat" : 28.09879190,
                                                                  "lng" : -15.44634850

            same City diferent   lat and long
« Last Edit: November 18, 2012, 01:38:35 pm by lucky_strike »


  • Guest
something like that..
:) some twaeks to get it working


  • Full Member
  • ***
  • Posts: 102
I love how you share your progress. 



  • Hero Member
  • *****
  • Posts: 622
  • I am founder of
great work i appreciate your hardwork i hope i will use it someday