Greetings,
I'm wondering what the best way to add something like this would be (Syntax may be off):
function CheckCube ($CubeID)
{
if () // Database looking to see if $CubeID has been registered
return true;
return false;
}
Which would be used on several pages...
I could put it into a snippet... But calling a snippet is painful.. OK, with arguments is fairly painful... (I can't imagine why there isn't a method of calling it using the same syntax that is found between the [[]]'s Why do I need an array of arguments, when clearly the other syntax must be handled somewhere...)
But what I really need is a simple import (like a Chunk, except being PHP code)...
Maybe something like {P FunctionName P} or something... And then a tab to manage the Function... OR just have the Function be a snippet...
(Or have the [[ syntax work within a snippet to include the source of another one, but I could see that as being confusing.)
Basically, I'd like to do this:
{P Functions P}
if (!CheckCube ($CubeID)) return "You selected an invalid CubeID, please check again!";
...
Two lines of code.. Yeah, I could cut/paste but that sux, and I could add it to index.php, but that is beyond suckage... Beyond that, I don't know of anyway to do this...
-Chert
--
www.runecube.com
Custom Functions....
Started by
traderhut
, Oct 04 2010 05:46 PM
3 replies to this topic
#1
Posted 04 October 2010 - 05:46 PM
#2
Posted 05 October 2010 - 08:27 AM
If you change manager / configuration / miscellaneous settings / allow embedded php - YES.
You can then go <?php ... your code here... ?> in a page or template no problem.
You can then go <?php ... your code here... ?> in a page or template no problem.
#3
Posted 05 October 2010 - 03:30 PM
If you change manager / configuration / miscellaneous settings / allow embedded php - YES.
You can then go <?php ... your code here... ?> in a page or template no problem.
Would I then use a code block? {{MyReusedFunctions}}
Which, I would start off with <?php
and wouldn't be HTML, but would be my functions that I want to use from multiple pages...
#4
Posted 05 October 2010 - 04:53 PM
When I am using functions across the entire page I usually place them in a snippet and then place a sinppet call in the <head> section of my page template... I don't recommend using a chunk to store PHP functions or classes... That is the purpose of snippets... You can also do external includes from within snippets...
Snippets are much more powerful than they have been given credit for having... I have done some fairly complex coding using snippets, the $etomite->runSnippet('snippet_name', array($params)) call, and several other tricks... I've also used $etomite->runSnippet() to retrieve snippet module configuration settings... I've even written entire applications just using Etomite Documents, Templates, Snippets, Chunks, and custom data tables...
And the following code is a chunk that is used to create custom database queries... A snippet parses the chunk to build the query which is then used to extract data which is then displayed by parsing yet another chunk...
And HERE is the site page that uses this code... Unfortunately, the site has not been maintained by the owner so the full capabilities have never been used... This same code has been modified and is being used on another large site but I cannot post a link to it due to confidentiality concerns... That page also utilizes a couple of session state save and retrieve functions so the Back button doesn't nag for resending, which I believe is still working...
Snippets are much more powerful than they have been given credit for having... I have done some fairly complex coding using snippets, the $etomite->runSnippet('snippet_name', array($params)) call, and several other tricks... I've also used $etomite->runSnippet() to retrieve snippet module configuration settings... I've even written entire applications just using Etomite Documents, Templates, Snippets, Chunks, and custom data tables...
And the following code is a chunk that is used to create custom database queries... A snippet parses the chunk to build the query which is then used to extract data which is then displayed by parsing yet another chunk...
SELECT
p.pid,
c.category,
p.date_posted,
p.hours,
p.status,
p.min_start_pay,
p.summary,
p.description,
r.fullname as recruiter,
r.phone,
p.show_recruiter_info,
p.published
FROM
{db}.job_categories as c,
{db}.job_posts as p,
{etoDB}user_attributes as r
WHERE
c.cid = p.category
AND
r.internalKey = p.recruiter
{filter}
And HERE is the site page that uses this code... Unfortunately, the site has not been maintained by the owner so the full capabilities have never been used... This same code has been modified and is being used on another large site but I cannot post a link to it due to confidentiality concerns... That page also utilizes a couple of session state save and retrieve functions so the Back button doesn't nag for resending, which I believe is still working...
0 user(s) are reading this topic
0 members, 0 guests, 0 anonymous users











