Open Source Services

Development Services and Products for Open Source e-Commerce Sites

 
Welcome, Guest
Please Login or Register.    Lost Password?
Log in to post your support questions and comments for this contribution.
Go to bottomPage: 1
TOPIC: Modifying Control Centre
#80
Modifying Control Centre 4 Years, 1 Month ago  
Hi,
I installed Adsense Control Center (ACC) v1.0 for osCommerce several days ago and have no issues what-so-ever.
I've had a play with it and everything works as you designed it to do.
An excellent contribution.
Thank you.

But....I'm never satisfied

I'd like to add another option to put the AdSense ad in more places. In particular within the page body itself.
I have product_info.php in mind.

There doesn't seem to be any additions needed for the database.

Before I go hacking around....
Could you please discuss with me whether this is a simple addition?
Which files would I need to edit?
etc

Regards
Jim
MDBA
Fresh Boarder
Posts: 5
graphgraph
User Offline Click here to see the profile of this user
The administrator has disabled public write access.
 
#81
Re:Modifying Control Centre 4 Years, 1 Month ago  
Hi Jim

Thanks for your kind words about ACC.

The extra functionality you want is something I'm planning for a future version. But if you fancy having a hack my initial thoughts on what needs doing are:

- creation of a new 'Position' constant (e.g. 'ACC_BODY' = 'Body'), which could be selected in the admin the page.

- you could then add the following code (or similar) within product_info.php where you want the ad(s) to appear:

Code:


<?php
$ads = get_adsense_info(ACC_BODY);
$placements = getPlacements($ads);
for($i=0; $i < count($placements); $i++) {
create_ad($placements[$i], $ads);
}
?>



I haven't had much time to revisit the code, so these ideas are just off the top of my head. Doubtless other issues will arise, but these would be my starting points.

If you do give it a try, please let me know how you get on.

regards

H.
hanuman
Moderator
Posts: 371
graph
User Offline Click here to see the profile of this user
The administrator has disabled public write access.
 
#90
Hacking underway 4 Years, 1 Month ago  
Hi H,
I actually started hacking as soon as I had posted.
Seem to have hit a snag I don't quite understand.

Firstly, I must point out I am a hacker, not a coder.
My first and only exposure to PHP started 2 years ago when I first installed OsC for our site.
So far, my methods have served me well and slowly I'm learning, but to think of me as a coder is an insult to real coders.

Ok...so far, I've searched and tried to understand your contribution.
From what I can see, admin/adsense_cc.php serves as an interface between the DB and the user.
It allows us to enter data into the DB and to view same.

I added a new line at line 367 of your original code.
Code:

<option <?php if(($show_values) && ($position == ACC_BODY)) echo 'SELECTED'; ?> value="<?php echo ACC_BODY; ?>"><?php echo ACC_BODY; ?></option>


I searched this file for any instance of the phrase ACC_HEADER and this was the only place I found it.
As you can see, I've merely duplicated your original line and just changed your original code from HEADER to BODY

Definitions were added in the language file.

So far so good.
Data appears in the DB as it should.(Browsed DB in PhPMyAdmin)

Next, the code for placement in the page(s) appears to merely say...."Use the code in catalog/includes/functions/adsense_cc.php to extract the data from the DB named BODY or HEADER etc and put it all together as Google code here please"

I searched that function and can see no reference to any specific position such as header etc.

I used my admin to create a body ad listing and having changed your page code ad suggested in your last post, I tested it.

No show!

But....Change the page code from BODY to HEADER or FOOTER and the relevant ad for each appears in the correct place in the body.

From my very limited experience, the function appears to not be finding the right line in the DB.
There are no line numbers.
Somewhere, there must be a line that instructs the site to select a particular line.
Presumably in an array somewhere.
But I can't find it.

I've obviously missed something.

One further very small niggle.

I added the code in product_info.php "More Information" line and the end of that table thus....

Code:

      <tr>
        <td align="center" class="smallTextMDBA"><?php echo sprintf(TEXT_DATE_AVAILABLE, tep_date_long($product_info['products_date_available'])); ?></td>
      </tr>
<?php
    } else {
?>
      <tr>
        <td align="center" class="smallText"><?php echo sprintf(TEXT_BREAKER, tep_date_long($product_info['products_date_added'])); ?></td>
      </tr>

      <tr>
          <td align="center"> 
            <?php
$ads = get_adsense_info(ACC_FOOTER);
$placements = getPlacements($ads);
    for($i=0; $i < count($placements); $i++) {    
        create_ad($placements[$i], $ads);
    }
?>
          </td>
      </tr>

      <tr>
        <td align="center" class="smallTextMDBA"><?php echo sprintf(TEXT_DATE_ADDED, tep_date_long($product_info['products_date_added'])); ?></td>
      </tr>



Simple....This is HTML.
I'm comfortable here.
So....How come I can't make it obey the align="center" tag???
It's aligning left.

Its always the simple things that stuff me up.

So....H....What have I missed do you think?
Oh....And Happy New Year.
Onwards and forward!
MDBA
Fresh Boarder
Posts: 5
graphgraph
User Offline Click here to see the profile of this user
Last Edit: 2007/12/30 23:26 By MDBA.
The administrator has disabled public write access.
 
#91
Re:Hacking underway 4 Years, 1 Month ago  
Hi Jim

as far as your small 'niggle' re alignment in the HTML goes, you need to make sure that
in the Admin section, you set

CSS Style Code: text-align:center;

in the 'Edit This Ad Unit' box.

Hope this helps. As for your main problem, I'll have to take a more detailed
look at the code later today.

Cheers

Hanuman
hanuman
Moderator
Posts: 371
graph
User Offline Click here to see the profile of this user
The administrator has disabled public write access.
 
#92
Re:Hacking underway 4 Years, 1 Month ago  
Jim

Regarding your main problem:

If - in the DB field 'position' the system is saving 'Body' (or somesuch),
and you are indeed using the line:

Code:

$ads = get_adsense_info(ACC_BODY);


within products_info.php, then the first thing I would make sure of is that you
have included the definition:

Code:

define('ACC_BODY','Body');


in BOTH language files. That is:

- catalog/admin/includes/languages/english/adsense_cc.php
- catalog/includes/languages/english/adsense_cc.php

Both the front and back-end components need access to the ACC_BODY constant.

Let me know if this was(n't) the problem.

Regards

Hanuman
hanuman
Moderator
Posts: 371
graph
User Offline Click here to see the profile of this user
The administrator has disabled public write access.
 
#93
Re:Modifying Control Centre 4 Years, 1 Month ago  
Well, that was the answer alright.
I would never have thought to look in the language files.
Thank you.

And your tip about the text align also worked a treat.

Everything now works exactly as I wanted.

To save you some time, here is exactly what I did so you can include it in future versions if you wish.
I’ve written it as one might a contribution.

Open and backup file: admin/adsense_cc.php

Find (line 366):
Code:

 <option <?php if(($show_values) && ($position == ACC_FOOTER)) echo 'SELECTED'; ?> value="<?php echo ACC_FOOTER; ?>"><?php echo ACC_FOOTER; ?></option>


Directly under, add:
Code:

 <option <?php if(($show_values) && ($position == ACC_BODY)) echo 'SELECTED'; ?> value="<?php echo ACC_BODY; ?>"><?php echo ACC_BODY; ?></option>


Save file and upload

Open and backup file: admin/includes/languages/english/adsense_cc.php

Find (Line 36)
Code:

 define('ACC_FOOTER','Footer');


Directly under add:
Code:

 define('ACC_BODY','Page Body');


Save file and upload

Repeat above instructions for catalog/includes/languages/english/adsense_cc.php substituting line 18 in the “Find” instruction.

Save file and upload

Open and backup file: catalog/product_info.php

Find: (lines 186 to 202 in an original, untouched copy)
Code:


<?php
    }

    if ($product_info['products_date_available'] > date('Y-m-d H:i:«»s')) {
?>
      <tr>
        <td align="center" class="smallText"><?php echo sprintf(TEXT_DATE_AVAILABLE, tep_date_long($product_info['products_date_available'])); ?></td>
      </tr>
<?php
    } else {
?>
      <tr>
        <td align="center" class="smallText"><?php echo sprintf(TEXT_DATE_ADDED, tep_date_long($product_info['products_date_added'])); ?></td>
      </tr>
<?php
    }
?> 



Directly under add:

Code:


      <tr>
        <td align="center" class="smallText"><?php echo sprintf(TEXT_BREAKER, tep_date_long($product_info['products_date_added'])); ?></td>
      </tr>

      <tr>
          <td> 
            <?php
$ads = get_adsense_info(ACC_BODY);
$placements = getPlacements($ads);
    for($i=0; $i < count($placements); $i++) {    
        create_ad($placements[$i], $ads);
    }
?>
          </td>
      </tr>



Save file and upload

Open and backup file: catalog/includes/languages/english/product_info.php

Add just before the final $>

Code:

define('TEXT_BREAKER', '* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *');

Save file and upload.

THAT'S IT!!! GO TO 'ADSENSE CONTROL' IN ADMIN->TOOLS->ADSENSE CONTROL AND ENJOY!!!

I also made a couple of very small modifications to admin/adsense_cc.php for your approval.

Line 294 has been changed to
Code:

 <td class="dataTableContent"><?php echo '<a class="headerLink" href="' . FILENAME_ADSENSE_CC . '?action=edit_ad&name=' . $adsense['name'] . '"><img style="border: none;" src="images/ icons/preview.gif"/></a>'; ?></td>


Note the addition of img style="border: none; to remove the blue border around the edit icon

Also, it appeared to me that underlining the words To create a new ad/link unit, click here:
Made it look as if the text itself was the link.
I figured….”Why not make it a link?”

I changed my copy as follows:
Line 327

I changed to this:
Code:


<td class="smallText" align="center"><?php echo '<a href="' . tep_href_link(FILENAME_ADSENSE_CC . '?action=create_ad') . '">' . 'To create a new ad/link unit, click here:' . '</a>'; ?>< a href="<?php echo FILENAME_ADSENSE_CC . '?action=create_ad'; ?>"><?php echo tep_image_button('button_new.gif', '', ''); ?></a></td>



No disrespect intended.
Just offering opinion and suggestion.

Thank you for all your help

Cheers
Jim Byers

(Text file of above post offered for your convenience)
This attachment is hidden for guests. Please login or register to see it.
MDBA
Fresh Boarder
Posts: 5
graphgraph
User Offline Click here to see the profile of this user
Last Edit: 2007/12/31 20:17 By MDBA.
The administrator has disabled public write access.
 
Go to topPage: 1