Results 1 to 9 of 9

Thread: Logic Hook Trouble

  1. #1
    lmiller is offline Sugar Community Member
    Join Date
    Feb 2010
    Posts
    106

    Default Logic Hook Trouble

    I posted this in the wrong thread, sorry I'm moving it right now


    I work for an SEO company, and I'm trying to make a logic hook that will check a checkbox when a value is less than 11. So I made an integer field, made the area 1-100, which is to be the website's ranking on Google(gpos_c), and I made a Checkbox for first page, so we can search for accounts on and off of the first page(lstpage_c)(I used an L in place of a 1). This is what my code is so far, but I'm getting no results at all.
    This is my first time doing this without being walked through it, so don't be surprised at simple mistakes
    PHP Code:
    <?php
    $hook_version 
    1;

    $hook_array = Array();
    $hook_array['before_save'][] = Array(1'1stpagehook''custom/modules/Account/1stpagehook.php''1stpagehook''convertToProper');

    ?>
    PHP Code:
    <?php

    /*************************************
    Project: Hook to sort by 1st page in numerical values
    Developer: Lane Miller
    Desc: Hook that will modify the field 1st page according to the numerical value in 

    the Google position field.
    The contents of this file are governed by the GNU General Public License (GPL).
    A copy of said license is available here: http://www.gnu.org/copyleft/gpl.html
    This code is provided AS IS and WITHOUT WARRANTY OF ANY KIND.

    *************************************/

    class 1stpagehook{

    function 
    convertToProper(&$bean$event$arguments){
        if (
    $bean->$gpos_c '11'){
            
    $bean->$lstpage_c "1";
        }

    }

    }

    ?>

  2. #2
    jsagar's Avatar
    jsagar is offline Sugar Community Member
    Join Date
    Mar 2008
    Location
    Ahmedabad,India
    Posts
    242

    Default Re: Logic Hook Trouble

    Hi,
    try replacing this code :
    PHP Code:
    if ($bean->gpos_c '11'){
            
    $bean->lstpage_c "1";
        } 

    hope it helps you.
    Best Regards
    ---------------------------------------
    Jaydeepsinh Sagar

  3. #3
    lmiller is offline Sugar Community Member
    Join Date
    Feb 2010
    Posts
    106

    Default Re: Logic Hook Trouble

    I'm not getting any response in the help section, but this is what my code is right now, but I'm still seeing no changes whatsoever
    PHP Code:
    <?php

    /*************************************
    Project: Hook to sort by 1st page in numerical values
    Developer: Lane Miller
    Desc: Hook that will modify the field 1st page according to the numerical value in the Google position field.
    The contents of this file are governed by the GNU General Public License (GPL).
    A copy of said license is available here: http://www.gnu.org/copyleft/gpl.html
    This code is provided AS IS and WITHOUT WARRANTY OF ANY KIND.

    *************************************/

    class 1stpagehook {

    function 
    convertToProper(&$bean$event$arguments){
        if (
    $bean->gpos_c '11'){ 
                
    $bean->lstpage_c "1";
    }    else{
            
    $bean->lstpage_c "0";
    }

    }

    ?>
    PHP Code:
    <?php
    $hook_version 
    1;

    $hook_array = Array();
    $hook_array['before_save'][] = Array(1'1stpagehook''custom/modules/Account/1stpagehook.php''1stpagehook''convertToProper');

    ?>
    why am i getting no changes at all? no matter what i do

  4. #4
    jsagar's Avatar
    jsagar is offline Sugar Community Member
    Join Date
    Mar 2008
    Location
    Ahmedabad,India
    Posts
    242

    Default Re: Logic Hook Trouble

    Hi,
    logic hook seems good.
    $hook_array['before_save'][] = Array(1, '1stpagehook', 'custom/modules/Account/1stpagehook.php', '1stpagehook', 'convertToProper');

    can you check that are you in right directory or not.?
    because custom/modules/Account/1stpagehook.php
    it should be Accounts not Account.

    hope it helps you.
    Best Regards
    ---------------------------------------
    Jaydeepsinh Sagar

  5. #5
    SugarDev.net is offline Sugar Community Member
    Join Date
    Feb 2008
    Posts
    1,401

    Default Re: Logic Hook Trouble

    Try rewriting your code to use integers, not strings, by removing the quotes around the numbers.
    Developers go here
    Businesses go there (Dutch)

    Modules:
    SugarDev.net Developer Tools | Config | Dutch Language Pack
    "Nothing gets fixed unless there is a bug"

  6. #6
    lmiller is offline Sugar Community Member
    Join Date
    Feb 2010
    Posts
    106

    Default Re: Logic Hook Trouble

    So I did have the directory wrong. After editing it, and trying the codes with different sets of quotes, I'm still seeing no changes, even when I comment out the if statement... here is what I have right now

    PHP Code:
    <?php 

    /************************************* 
    Project: Hook to sort by 1st page in numerical values 
    Developer: Lane Miller 
    Desc: Hook that will modify the field 1st page according to the numerical value in the Google position field. 
    The contents of this file are governed by the GNU General Public License (GPL). 
    A copy of said license is available here: http://www.gnu.org/copyleft/gpl.html 
    This code is provided AS IS and WITHOUT WARRANTY OF ANY KIND. 

    *************************************/ 

    class 1stpagehook 

    function 
    convertToProper(&$bean$event$arguments){ 
        if (
    $bean->gpos_c 11 ){  
                
    $bean->lstpage_c 
    }    else{ 
            
    $bean->lstpage_c 




    ?>
    PHP Code:
    <?php
    $hook_version 
    1;
    $hook_array = Array();
    $hook_array['before_save'] = Array(1'1stpagehook''custom/modules/Accounts/1stpagehook.php''1stpagehook''convertToProper');

    ?>
    Last edited by lmiller; 2010-05-27 at 03:49 PM. Reason: Typo

  7. #7
    SugarDev.net is offline Sugar Community Member
    Join Date
    Feb 2008
    Posts
    1,401

    Default Re: Logic Hook Trouble

    Please provide the location of logic_hooks.php.
    Developers go here
    Businesses go there (Dutch)

    Modules:
    SugarDev.net Developer Tools | Config | Dutch Language Pack
    "Nothing gets fixed unless there is a bug"

  8. #8
    lmiller is offline Sugar Community Member
    Join Date
    Feb 2010
    Posts
    106

    Default Re: Logic Hook Trouble

    /public_html/custom/modules/Accounts

  9. #9
    cs3gallery's Avatar
    cs3gallery is offline Senior Member
    Join Date
    Mar 2010
    Location
    St. George, Utah
    Posts
    71

    Default Re: Logic Hook Trouble

    Lets go over your code and change a few things just to make sure zero mistakes are being made.


    I would personally change your code to this:

    PHP Code:
    <?php 

    /************************************* 
    Project: Hook to sort by 1st page in numerical values 
    Developer: Lane Miller 
    Desc: Hook that will modify the field 1st page according to the numerical value in the Google position field. 
    The contents of this file are governed by the GNU General Public License (GPL). 
    A copy of said license is available here: http://www.gnu.org/copyleft/gpl.html 
    This code is provided AS IS and WITHOUT WARRANTY OF ANY KIND. 

    *************************************/ 

    class pagehook 

    function 
    convertProper(&$bean$event$arguments) {

    //set variables
    $google $bean->gpos_c;
    $page $bean->lstpage_c;

    //begin argument 
        
    if ($google =< "10") {  
                
    $page "1"
        }else{ 
                
    $page "0"
      } 



    ?>
    Give this a try and dont forget to change the logic hook according to the changed names. Please let me know if this works... if not I have a solution that should surely work.

    I also know that I did not have to add variables but I like to keep my code as clead and good looking as possible.
    ______________________
    Ubuntu 10.04 LTS Server
    Apache 2.2.3
    MySQL 5.1
    PHP 5.2.12
    Sugar 5.5.4
    ______________________

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Replies: 10
    Last Post: 2010-11-16, 02:41 AM
  2. Help on my first logic hook.
    By amrutha in forum Developer Help
    Replies: 9
    Last Post: 2009-11-24, 01:29 PM
  3. Which logic hook, where?
    By dantrainor in forum Developer Help
    Replies: 0
    Last Post: 2009-09-04, 07:17 AM
  4. Replies: 3
    Last Post: 2009-08-15, 03:00 AM
  5. logic hook
    By atik in forum Developer Help
    Replies: 2
    Last Post: 2009-03-28, 10:47 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •