• Welcome to the Chevereto user community!

    Here users from all over the world gather around to learn the latest about Chevereto and contribute with ideas to improve the software.

    Please keep in mind:

    • 😌 This community is user driven. Be polite with other users.
    • 👉 Is required to purchase a Chevereto license to participate in this community (doesn't apply to Pre-sales).
    • 💸 Purchase a Pro Subscription to get access to active software support and faster ticket response times.

Adding tables to database for adverts

inept

Chevereto Member
I'm wondering how hard it would be to add a extra table to the image database.

upon an upload of an image this table would be default "0"

i could then go into the database and change it to "1" "2" "3" or anything i wanted.

then I want to put code on my site so when an image is viewed in the viewer.

eg. http://mysite.com/image/ihihoj

the code would then check the database entry for that image and look at the new table i created and depending on the value use different ad code.

so "0" would be no ad
"1" would be my adsense code
"2" would be a different ad code.
 
You want to do something like go to the dB and select which ad will be displayed?
 
just go to phpmyadmin, crete table.. fill the fields, that's all.. Look at the chv_options ;)
you can also use the config file for that, then you won't need db to do the same.
 
thanks, did not think of just adding it like that. should have really.

do you know how i would go about writing the code to search the database and then depending on what value it finds put the ad on the site?

im new to this so i kinda work stuff out with trail and error.

but i have been looking and im unsure if im looking at the right place.

been looking at sql query's but i have not found a tut that shows me how to do what i want to do.

something like.

connect to database
chv_images
check column "ads" for value for image displayed

if "0"

(dont display any code)

if "1"

(dont display any code)

if "2"

display adsense code

if "3"

display alternative ad code


im not expecting you to write this code for me, for a start your a busy man and really theirs no reason for you to waste your time on this for me.

but if you can link me to a tut which explains how i would do this or point me in the right direction so i can have a better chance of working this out on my own then i would be grateful.
 
You must create a table where you will store the different status_ids, like a "ad_codes" table. In this table you will have this rows:
  • Row 1: adsense code 1
  • Row 2: Different ad code
  • Row n: Etc...
With the structure: field1: "id" int (unique), field2: "code" (varchar). In this table you will have all the possible ad codes as rows. At this point you already have the possible adcodes stored in the databse, now you will need to make the relation or "what rown will be used".

You can use the table chv_options and add a row there, that could be your "current_ad_id", a configurable value. This row will store the relation, like "this code will be used".

Finally, in Chevereto, you can use the database class to select the ad code by making a relationship between the "current_ad_id" and the "ad_codes" table.

This can be complicated if you don't know how to do it and in my opinion you don't need database to do this. The first rule of databases is "use only if you really need it". Database will be suitable if you have a front end administration and a large number of ad rows, you at this moment are in square one with no database structure, no rows, no front-end administration.

Like I said, you can simply have a config value that points to a different ad, something like $config['my_ad'] = $ad1; and then you only need to have $ad1 = "<adcodehere">; $ad2 = "<adcode2>"; etc... Then, if you change $config['my_ad'] = $ad2; you will use the other code. Is that simple.
 
thanks for the reply.

but thats like me reading french. :)

i dont really know what im looking at but as long as its all there i will try working it out.

so will this give different ads on different image viewers depending on a value i choose?

so i have added a row called "ads" to chv_images

and depending on what value i put in here different ads will be shown on different images on their viewer page.

so for example

image1 http://mysite..com/image/FHwgc
i set "ads" in chv_images for this image to "0" and it shows no ads

image2 http://mysite..com/image/bdaGHFH
i set "ads" in chv_images for this image to "2" and it shows ad code 2

image3 http://mysite..com/image/eq234C
i set "ads" in chv_images for this image to "3" and it shows ad code 3

image4 http://mysite..com/image/BqdsgC
i set "ads" in chv_images for this image to "1" and it shows no ads

what code would i be putting on the viewer page in order for it to check the ads value of the image and place the ad code from "ad_codes" table for that value.

once again thanks for helping me with this.

i know you dont really need to.
 
I really don't understand what you want. You want a random ad code? Each image with a configurable ad code?
 
Google adsense has rules.

No adult content.

My site got temp banned due to adult images, contacted google and they were cool about it but I don't want to put adsense on my site until I can configure the ad for each image.

I want to beable to choose what ad shows on each image.
So adult images get adult adverts and non adult images get adsense.

This makes it alot easier as I cannot play catch up by checking uploaded images everyday to remove adult images so I don't get temp banned again.

So I want a way I can log into phpmyadmin and check each image for banned content and porn then give the image a value so the viewer page for that image shows a relevant advert.

So values would be something like
0 (default) = image not checked and no adverts run
1 = image checked but don't run adverts
2= non adult image - display adsense code on image viewer
3 = adult image - display adult advert on image viewer page.

So I want a quick way for me to display diffrent ads on diffrent images depending on image content.
 
I see. Well, that is like I said quite hard to implement because you need a control panel to understand that. Either way you will ned to use phpmyadmin for that. I'm pretty up with this issue and I have even included adsense in the demo for that, I'm testing things. This could be easily implemented with a NSFW/SFW feature. That will be mostly in 3.X
 
Can you point me in the right direction so I can at least see if I can work something out?

Give me something to google or link me to some tutorials for the work that will need to be done?

I want to take a bash at it myself as I want to try get adverts back up asap

Thanks
 
The no friendly way is pretty easy.. Just add a new field in the chv_images table, something like "ad_flag" then create a new table called "ad_codes" with an id (integer) field and a varchar field. Then for each ad_code create a new row in "ad_codes". Then, in the images manually set the "ad_flag" to the id (0,1,2,3) that will be taken from the ad_codes.

Then, in the database class search for the function that fetch the image details and workaround to get the "ad_flag" id. Then, with this id do a new PDOQuery to get that code and fianly asign that code into a temp variable or a template tag and you are done. Remember... that is the "easy" way =/
 
i will see if i can work that out.

thanks for this.

is this "easy way" going to cause any problems with the site you can think of making it not worth it, like adding way too much extra load on my site causing it to slow it down by a great amount?
 
i will see if i can work that out.

thanks for this.

is this "easy way" going to cause any problems with the site you can think of making it not worth it, like adding way too much extra load on my site causing it to slow it down by a great amount?

No, I don't think so.
 
Back
Top