CodeCharge Studio
search Register Login  

Visual Web Reporting

Visually create Web Reports in PHP, ASP, .NET, Java, Perl and ColdFusion.
CodeCharge.com

YesSoftware Forums -> CodeCharge Studio -> PHP

 [Resolved] Include Generic PHP Functions

Print topic Send  topic

Author Message
maxhugen

Posts: 272
Posted: 07/19/2008, 7:40 PM

I'm wondering what is the best way to 'include' some generic PHP functions?

For example, in a website that features short stories, each time a Story page is called, I'd like to run a function that updates a story 'number_of_views' count.

It seems that perhaps I should create an Include page, with no html at all, and just a custom php function in the code somewhere. Basically, I'm trying to avoid having to add identical code to each and every Story page.

However, I'm not at all sure this is the best approach. Any suggestions pls?
_________________
Max
www.gardenloco.com | www.eipdna.com | www.chrisarminson.com
View profile  Send private message
wkempees


Posts: 1679
Posted: 07/20/2008, 1:54 AM

Max,
on mobile browser cannot copy paste links, but
use search forum, search for
' Add php library '
will give thread ' [Solve] ....... ' it explains one method to do what you want, without any editing of common files, post here if you need more assist or the other methods.

Walter


_________________
Origin: NL, T:GMT+1 (Forumtime +9)
CCS3/4.01.006 PhP, MySQL .Net/InMotion(Vista/XP, XAMPP)

if you liked this info PAYPAL me: http://donate.consultair.eu
View profile  Send private message
mentecky

Posts: 321
Posted: 07/20/2008, 4:29 PM

In almost every project I do I have a PHP file that holds all my custom functions. I open Common.PHP and add my include in the first white space just under CCS's includes. 99% of the time it survives upgrades and re-generation. If for some reason it gets deleted I just add it there again with one line of code.

Rick
_________________
http://www.ccselite.com
View profile  Send private message
maxhugen

Posts: 272
Posted: 07/20/2008, 5:02 PM

Thanks Walter, Rick

I added the include to each of my existing Story pages in the AfterInitialize event, and to my 'Story' template, as per the post at:

http://forums.yessoftware.com/posts.php?post_id=97820&s...add+php+library

Prefer that to changing the Common.php file, as knowing myself, I'd likely forget I put it there and have probs if CCS dropped it during a regeneration!

Cheers, Max
_________________
Max
www.gardenloco.com | www.eipdna.com | www.chrisarminson.com
View profile  Send private message
mentecky

Posts: 321
Posted: 07/20/2008, 5:27 PM

Darnit! I hate when Walter beats me to an answer! :-D

My answer was more global to the site, but Walter is right. If it's only needed in limited pages then that's where it belongs and will survive re-gens better.

Rick

PS: Not that this is a competition or anything. LOL
_________________
http://www.ccselite.com
View profile  Send private message
wkempees


Posts: 1679
Posted: 07/21/2008, 6:20 AM

Rick, PS taken, lol
Max, good choice.
There is a third method, if I remember well by Feha, in which you alter common.php and from then on a designated directory (functions) is always scanned for given paternnamed files and they are included all.
But the method Max has chosen is preffered by me.

Walter
_________________
Origin: NL, T:GMT+1 (Forumtime +9)
CCS3/4.01.006 PhP, MySQL .Net/InMotion(Vista/XP, XAMPP)

if you liked this info PAYPAL me: http://donate.consultair.eu
View profile  Send private message
jjrjr1


Posts: 942
Posted: 07/22/2008, 11:29 AM

I hate to mess up the works here But...

I have successfully done the same thing but by creating a CCS include page with no HTML.

One of the advantages doing it this way is, I can create record builder items into the common include file and easily get database values, process them based on events, and easily modify database access to common values if required to come from tables. This way I do not have to write any queries manually and have all the power of CCS database, and all the other functions available. (BTW when you do it this way all you have to do is remove all the text the record builder creates and make all the data fields hidden.)

One thing great about programming is there is always more than one way to skin a cat. All good usually.

Have fun.

_________________
John Real - More CodeCharge Studio Support at - http://CCSElite.com
View profile  Send private message
maxhugen

Posts: 272
Posted: 07/22/2008, 3:48 PM

G'day John

Thanks for throwing in your method, I like it. I saw some advantages when I first considered a CCS Include page, which you just pointed out. Being a noobie though, I was wondering if I'd be shooting myself in the foot!
_________________
Max
www.gardenloco.com | www.eipdna.com | www.chrisarminson.com
View profile  Send private message

Add new topic Subscribe to topic   


These are Community Forums for users to exchange information.
If you would like to obtain technical product help please visit http://support.yessoftware.com.

PHP Reports

Visually create Web Reports in PHP, ASP, .NET, Java, Perl and ColdFusion.
CodeCharge.com

Home   |    Search   |    Members   |    Register   |    Login


Powered by UltraApps Forum created with CodeCharge Studio
Copyright © 2003-2004 by UltraApps.com  and YesSoftware, Inc.