Profile
Achievement
beneberle's Recent PHP Snippets
- All /
« Prev 1 Next »
Condition = The condition which must be met.
True = Executed if the condition is met.
False = Executed if the condition failes.
0
553
posted 12 years ago by beneberle
getCategory returns the category ID, getSection returns the section alias. Great for CSS overrides
0
725
posted 12 years ago by beneberle
function for determining the section ID of a given page. Good to include in a templatetools.php file inside of a template to set up some custom conditional logic
0
665
posted 12 years ago by beneberle
Though an old post, this is my solution that's been pieced together from various comments on the article linked above.
1
1096
posted 13 years ago by beneberle
I set up an $isHome boolean variable at the beginning of a template's index.php file so I can easily test the condition throughout the file. To me, the semantic variable name makes the logic more readable.
0
482
posted 13 years ago by beneberle
I needed to trim a simple numerical array that might have duplicate values into an array with no duplicates. I came up with this before finding array_unique(). D\'oh.
0
711
posted 13 years ago by beneberle
Substitute new_ placeholder in the second line with your new prefix. Run it: http://www.yoursite.com/rename.php and wait until it responds with an OK, usually after a couple of seconds. Delete the rename.php script. Edit the configuration.php file...
0
759
posted 13 years ago by beneberle
To make an image browser, add these lines:
$ext = strtolower(substr("$dirArray[$index]", strrpos("$dirArray[$index]", '.') + 1)); //get file extensions
if ("$ext" == "jpg") { // if file is a jpg
print("<TR><TD>$dirArray[$index]<br/><a href=\...
1
596
posted 14 years ago by beneberle