Never been to TextSnippets before?

Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world (or not, you can keep them private!)

About this user


« Newer Snippets
Older Snippets »
Showing 21-40 of 52 total

CSS Switcher Code

{exp:css_switcher}<link rel='stylesheet' type='text/css' media='all' href='{file}' />{/exp:css_switcher}

<form action="" method="post">
<select name="css_skin" id="css_skin">
<option value="1">Option 1option>

Code for using the CSS Switcher plugin. Insert this anywhere in a EE template where you want this to show.

Edit Link In An Entry

Without the Snippets plugin (ie, straight on the template itself):

{if member_group == "1"}
<a href="/system/index.php?C=edit&M=edit_entry&weblog_id={weblog_id}&entry_id={entry_id}" title="Edit Entry">Edit Thisa>

With the Snippets plugin (ie, included in a seperate template that gets pulled into all other templates):

{if member_group == "1"}
<a href="/system/index.php?C=edit&M=edit_entry&weblog_id=%editweblog%&entry_id=%editweblog2%" title="Edit Entry">Edit Thisa>

And use this to include the editlink template:

{exp:snippets template="static/editlink"}

Number of Entries in Galleries

All Galleries:
{exp:query sql="SELECT count(entry_id) AS count FROM exp_gallery_entries"}{count}{/exp:query}

One specific Gallery:
{exp:query sql="SELECT count(entry_id) AS count FROM exp_gallery_entries WHERE gallery_id=1"}{count}{/exp:query}

List of Stats

{exp:stats weblog="not 1|2"}
<li>Since 2001, I have posted <strong>{total_entries}strong> entries,</li>
<li>and received <strong>{total_comments}strong> comments.</li>
<li><strong>{total_guests}strong> people are currently browsing the site,</li>
<li>the most people online at the same time was <strong>{most_visitors}strong> on {most_visitor_date format="%M %d, %y"}</strong>.li>

Last Edited Entries

{exp:weblog:entries weblog="epguide" orderby="edit_date" limit="5"}

Categories For One Entry

{categories backspace="4"}<a href="{path=weblog/index}">{category_name}a> > {/categories}

List All Entries

{exp:weblog:entries weblog="weblog"}
<li><a href="{url_title_path=template/view}">{title}a></li>

Content-sensitive, so putting this on a main index page will list all entries there are, on a category page all entries in that category, and on a date archive page all entries for that month.

List All Categories

{exp:weblog:categories weblog="name" show_empty="no" id="left_nav"}
<a href="{path="template"}">{category_name}a>

Trim a line of text to X characters

 $varshort = substr($var,0,25); echo "$varshort"; ?>

Clean Up Form Input

// trim spaces from the beginning and the end of the variable
$field_name = trim($field_name);

// strip all HTML from the variables
$field_name = strip_tags($field_name);

// change the case of the variable to capitalize (It Will Look Like This - handy for Name fields)
$field_name = ucwords(strtolower($field_name));

// change the case of the first character to uppercase, the rest to lowercase (It will look like this)
$field_name = ucfirst(strtolower($field_name));

//change the case of the variable to lowercase
$field_name = strtolower($field_name);

// change the case of the variable to uppercase
$field_name = strtoupper($field_name);

Back and Forward Links in History

Using form buttons:

<input type="button" value="Back" onclick="history.back()">
<input type="button" value="Forward" onclick="history.forward()">
<input type="button" value="Reload" onclick="location.reload()">

Using a normal link:

<a href="javascript:history.back();">Backa>

Trim/Remove Spaces

To remove multiple occurences of whitespace characters in a string an convert them all into single spaces, use this:

$text = preg_replace('/\s+/', ' ', $text);

Strip whitespace (or other characters) from the beginning and end of a string

$variable = trim($variable);

How To Manually Update Cpanel


/scripts/upcp --force

How To Restart Services

Restart Apache:
service httpd restart

Restart Services:
service chkservd restart

Restart Cpanel:
/etc/init.d/cpanel restart

Restart Bind:
service named start

Run anything in /scripts:

How To Locate Files

lsof | grep searchterm

How To Fix Bandwidth Updating

If bandwidth stats aren't updating:

/scripts/runweblogs username

How To Fix 403 Errors for public_html

If all the public_html folders got their permissions wrong:

chmod 755 /home/*/public_html

How To Empty /var

If /var is too full:

cd /var
du -sh *

If the log directory is the problem:

rm -f /var/log/*.1
rm -f /var/log/*.2
rm -f /var/log/*.3
rm -f /var/log/*.4

(The /var/log directory contains archived files that always end with a number: exim_mainlog.1. Any file ending with a number can be safely deleted.)

If the problem is with the exim_mainlog being too large, try rotating the logs:

/usr/sbin/logrotate -vf /etc/logrotate.conf

If you get an error about a duplicate log entry:

cd /etc/logrotate.d
rm -rf httpd.rpmorig.log

And try the rotate again.

If the problem is in spool:

cd /var/spool/exim/msglog
rm -rf *

How To Empty /usr

cd /usr/local/apache/domlogs/
rm -rf *.*
/scripts/restartsrv httpd

How To Empty /backup

If /backup/ is too full:

cd /backup/cpbackup/monthly/
rm -f *.gz
/scripts/restartsrv httpd

Check the space after this, and it should be fine.

« Newer Snippets
Older Snippets »
Showing 21-40 of 52 total