Tags

Contents

Using a tag

Just put it where you want it in a template like <title>{title}</title>. For a list of tags distributed with CMS Made Simple, take a look in the plugins directory, or see the list of core tags.

Tag parameters

Many tags accept parameters, which allow you to refine their output; for example: {last_modified_by} would return the ID of the last user to modify a page; {last_modified_by format='fullname'} would output that user's full name instead.
Acceptable parameters will be listed on the tag's help page.

Using a tag value as another tag's parameter

If you wish to use the value of the output of one tag as a parameter in another, use Smarty's {capture} function to assign the value to a variable:
  {capture assign='tmp'}{title}{/capture}
Then call the variable in the parameter of the second tag:
 {news category=$tmp}

Installing a tag

To install a new tag, put the function.tagname.php file into your /plugins directory. When you refresh the Tags page in the CMS, the new tag will be shown.
Occasionally, tag installation will require extra steps; see PiSearch, for example. In this case, read the instructions supplied with the new tag.

Adding a parameter to a tag/plugin

Many tags/plugins are developed with default values that determine the behavior of the tag. However most tags also have optional parameters that can further refine the behavior of the tag/plugin.
For Instance, there is a plugin called "tagcloud". To add a parameter to a plugin like TagCloud, you do this...
Insert the smarty tag for the plugin into your template at the location you want the tag to show up on your web page. So for "tagcloud" you would insert the following code into the template where you want the tag cloud to appear.
 {tagcloud} 
Now if you want to also use parameters to modify the default behavior of the tag, you add them one after another in the tag that you just placed into your template. For instance, if you want to create a blacklist of words that will not show up in your tag cloud, then you enter the name of the parameter followed by a comma delimited list of the blacklisted words...
  {tagcloud blacklist="cms,template,code,cmsms"} 
If you wanted to modify more than one parameter, you would just add them to what you've already done, making sure you separate each new parameter from the previous parameter by a space.
So if you want to add a blacklist and also limit the number of tags that show in the cloud (the default is 30) you would use two parameters to do this, the "blacklist" parameter and the "max_words" parameter.
  {tagcloud blacklist="cms,template,code,cmsms" max_words="20"} 

How to use the Google Adsense Tag in CMSMS

The basic tag is {adsense}.
  • Login to your website Admin Console
  • Select "Content/Pages"
  • Click the name of the page you wish to edit
  • Type {adsense} wherever you want your adsense to appear
No - you're not done yet :-)

Adding the parameters to make it work for your unique Google account code

If you have already signed up for Google Adsense, you will have logged into that account and found the code provided by Google for all of the different ad formats. All you have to do is use the CMS Made Simple tag, and add the relevant info.
Here is a sample tag for a 120 wide and 240 high advert:
  {adsense
  ad_client="pub-1122334455whatever"
  ad_width="120"
  ad_height="240"
  ad_format="120x240_as"
  ad_type = "text"
  ad_channel = "type-OTHER-google-channel-number-here" 
  color_border = "FFFFFF"
  color_bg = "FFFFFF"
  color_link = "6600FF"
  color_url = "008000"
  color_text = "008000"
  }
  • Go ahead and put your Adsense tag into your CMSMS page.
  • Click the APPLY button, view it 'live'.
  • If you're happy with it, click SUBMIT button.

How to make the Adsense code appear on the left or right, with text flowing around it

This can be achieved very simply by using the DIV code.
BUT - the DIV code must be entered in the HTML source part of your EDIT screen - NOT THE EDIT PART - look for a little 'HTML' button in the menu for the Edit area of the Admin Panel.
  • Click the HTML button
  • a new little window opens, showing all the html code for the editable area of your page
  • find the Adsense tag, and put the DIV tag on either side of it, like this:
  <div>{adsense}</div>
  <div style="float: left; width: 140px; margin-top: 0px; margin-left: 3px">
  {adsense
  ad_client="pub-1122334455whatever"
  ad_width="120"
  ad_height="240"
  ad_format="120x240_as"
  ad_type = "text"
  ad_channel = "type-OTHER-google-channel-number-here" 
  color_border = "FFFFFF"
  color_bg = "FFFFFF"
  color_link = "6600FF"
  color_url = "008000"
  color_text = "008000"
  }
  </div>
Tip: Make the width of the DIV slightly larger than the width of the ad.
For alignment on the page, simply change - float: left; - to - float: right; - or centre.
Hope this helps!
--WebGirl 19:27, 6 October 2007 (CDT)

Tag specific help

There are a lot of tags available for CMS Made Simple and that amount is still growing. For some tags people put some information on this site which might help you installing or working with that modules. The pages referenced here might be outdated though or even not valid at all, anymore. Don't read all these pages unless you are installing or using that particular tag.
Click the Help (new window) icon at the upper right corner on the tag's help page. Sometimes you get the desired information.

Anchor Tags

To put a link at the bottom of each page that directs you straight to the top of that page (or any other position) you need an anchor link
To make a proper anchor link just insert the tag into your template/page like:
{anchor anchor='pagetop' text='go up'}
It needs a target somewhere after the <body> tag:
<a name="#pagetop"> </a>


Modified contact form

<?php
#CMS - CMS Made Simple
#(c)2004 by Ted Kulp (wishy@users.sf.net)
#This project's homepage is: http://cmsmadesimple.sf.net
#
#This program is free software; you can redistribute it and/or modify
#it under the terms of the GNU General Public License as published by
#the Free Software Foundation; either version 2 of the License, or
#(at your option) any later version.
#
#This program is distributed in the hope that it will be useful,
#but WITHOUT ANY WARRANTY; without even the implied warranty of
#MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#GNU General Public License for more details.
#You should have received a copy of the GNU General Public License
#along with this program; if not, write to the Free Software
#Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA

function smarty_cms_function_contact_form_attachment($params, &$smarty) {
	$gCms = cmsms(); //global $gCms;

	if (empty($params['email'])) {
		echo "Missing parameter 'email' - check plugin call";
		return;
	}

	if (isset($_POST["cf_submit"])) {

		$err = '';

		$to = $params['email'];

		$email = '';
		if (!empty($_POST['cf_email'])) {
			$email = trim($_POST['cf_email']);
			if (!sendmail::Validate_email($email)) $err .= '<li>Wrong format of e-mail adress!</li>';
		}
		else $err .= '<li>Where is Your e-mail?</li>';

		$name = '';
		if (!empty($_POST['cf_name'])) $name = trim($_POST['cf_name']);
		else $err .= '<li>Where is Your name?</li>';

		$subject = '';
		if (!empty($_POST['cf_subject'])) $subject = trim($_POST['cf_subject']);
		else $err .= '<li>Where is subject of Your message?</li>';

		$msg_part1 = '';
		if (!empty($_POST['cf_msg_part1'])) $msg_part1 = trim($_POST['cf_msg_part1']);
		else $err .= '<li>Where is part_1 of Your message?</li>';

		$msg_part2 = '';
		if (!empty($_POST['cf_msg_part2'])) $msg_part2 = trim($_POST['cf_msg_part2']);
//		else $err .= '<li>Where is part_2 of Your message?</li>';

		$msg_part3 = '';
		if (!empty($_POST['cf_msg_part3'])) $msg_part3 = trim($_POST['cf_msg_part3']);
		else $err .= '<li>Where is part_3 of Your message?</li>';

		$file_name = '';
		if (!empty($_FILES['cf_file'])) {
			$file_name = "_cf_".$_FILES['cf_file']['name'];
			$dest_file = $gCms->config["uploads_path"]."/".$file_name;
			$try = 0;
			while (file_exists($dest_file)) {
				$file_name = $try."_cf_".$_FILES['cf_file']['name'];
				$dest_file = $gCms->config["uploads_path"]."/".$file_name;
				$try++;
			}
			$file_name = $dest_file;
			if (!move_uploaded_file($_FILES['cf_file']['tmp_name'], $file_name)) {
		        $err .= "<li>Cannot move uploaded file to upload destination.</li>";
			}
		}
		if (!empty($file_name)) {
			if (($_FILES['cf_file']['error'])>0){
	        	$err .= '<li>File is larger then limit 100kB, or there is other error with upload.</li>';
			}
		}
		else $err .= '<li>Where is Your file?</li>';

		if (empty($err)) {
			$message_body = "Message part 1: ".$msg_part1;
			$message_body .= ", message part 2: ".$msg_part2;
			$message_body .= ", message part 3: ".$msg_part3;
			$sendmail = new sendmail();
			$sendmail->SetCharSet("ISO-8859-1");
			$sendmail->from($name,$email);
			$sendmail->to($to);
			$sendmail->subject($subject);
			$sendmail->text($message_body);
			if (!empty($file_name)) $sendmail->attachment($file_name);
			if ($sendmail->send()) {
				echo '<div class="contactForm">';
				echo 'Thank You for Your message.';
				echo '</div>';
			}
			else echo '<ul class="error">Problem with sending e-mail message.</ul>';
			return;
		}
		else {
			echo '<ul class="error">'.$err.'</ul>';
		}
	}

	echo '<div class="contactForm">';
	echo '<form action="'.$_SERVER['PHP_SELF'].'?'.$_SERVER['QUERY_STRING'].'" method="post" enctype="multipart/form-data">';
	echo '<input type="hidden" name="MAX_FILE_SIZE" value="100000" />';
	echo '<p>Your name</p>';
	echo '<input type="text" name="cf_name" value="'.$name.'" size="50" />';
	echo '<p>Your e-mail</p>';
	echo '<input type="text" name="cf_email" value="'.$email.'" size="50" />';
	echo '<p>Subject</p>';
	echo '<input type="text" name="cf_subject" value="'.$subject.'" size="50" />';
	echo '<p>part_1 of message</p>';
	echo '<input type="text" name="cf_msg_part1" value="'.$msg_part1.'" size="50" />';
	echo '<p>part_2 of message</p>';
	echo '<input type="text" name="cf_msg_part2" value="'.$msg_part2.'" size="50" />';
	echo '<p>part_3 of message</p>';
	echo '<textarea name="cf_msg_part3" cols="50" rows="10">'.$msg_part3.'</textarea>';
	echo '<p>file for upload</p>';
	echo '<input type="file" name="cf_file">';
	echo '<p>';
	echo "<input type=\"checkbox\" onclick=\"document.getElementById('cf_submit').disabled=!document.getElementById('cf_submit').disabled;\" />  ";
	echo 'YES, I agree with BLABLABLABLA</p>';
	echo '<input type="submit" id="cf_submit" name="cf_submit" value="SEND" disabled="disabled" />';
	echo '</form>';
	echo '</div>';
}

function smarty_cms_help_function_contact_form_attachment() {
   ?>
   <h3>What does this do?</h3>
   <p>Simple contact form with attachment. This can be used to allow others to send
   an email message to the address specified.</p>
   <h3>How do I use it?</h3>
   <p>Just insert the tag into your template/page like: <code>{contact_form_attachment email="anybody@anywhere.org"}</code></p>
   <h3>What parameters does it take?</h3>
   <ul>
      <li>email - The email address that the message will be sent to.</li>
   </ul>
   </p>
   <?php
}

function smarty_cms_about_function_contact_form_attachment() {
   ?>
   <p>Version: 1.0</p>
   <?php
}

class sendmail {
	var $emailheader = "";
	var $textheader = "";
	var $textboundary = "";
	var $emailboundary = "";
	var $charset = "";
	var $emailsubject = "";
	var $emailto = "";
	var $attachment = array();
	var $cc = array();
	var $bcc = array();

	function sendmail() {
		$this->textboundary = uniqid(time());
		$this->emailboundary = uniqid(time());
		$this->charset = "ISO-8859-1";
	}

	function SetCharSet($char) {
		$this->charset = $char;
	}

	function Validate_email($email) {
		if (!preg_match("/[a-z0-9_-]+(\.[a-z0-9_-]+)*@([0-9a-z][0-9a-z-]*[0-9a-z]\.)+([a-z]{2,4})/i",$email)) {
			return false;
		}
		return $email;
	}

	function from($name,$email) {
		$this->emailheader .= 'From: '.$name.'<'.$email.'>'."\r\n";
	}

	function to($to) {
		$this->emailto = $this->Validate_email($to);
	}

	function cc($cc) {
		$this->cc[] = $cc;
	}

	function bcc($bcc) {
		$this->bcc[] = $bcc;
	}

	function makeMimeMail() {
		if(count($this->cc) > 0) {
			$this->emailheader .= 'Cc: ';
			for($i=0;$i<count($this->cc);$i++) {
				if($i > 0) $this->emailheader .= ',';
				$this->emailheader .= $this->Validate_email($this->cc[$i]);
			}
			$this->emailheader .= "\r\n";
		}

		if(count($this->bcc) > 0) {
			$this->emailheader .= 'Bcc: ';
			for($j=0;$j<count($this->bcc);$j++) {
				if($j > 0) $this->emailheader .= ',';
				$this->emailheader .= $this->Validate_email($this->bcc[$j]);
			}
			$this->emailheader .= "\r\n";
		}
		$this->emailheader .= 'MIME-Version: 1.0'."\r\n";
	}

	function subject($subject) {
		$this->emailsubject = $subject;
	}

	function text($text) {
		$this->textheader .= 'Content-Type: multipart/alternative; boundary="'.$this->textboundary.'"'."\r\n\r\n";
		$this->textheader .= '--'.$this->textboundary."\r\n";
		$this->textheader .= 'Content-Type: text/plain; charset="'.$this->charset.'"'."\r\n";
		$this->textheader .= 'Content-Transfer-Encoding: quoted-printable'."\r\n\r\n";
		$this->textheader .= strip_tags($text)."\r\n\r\n";
		$this->textheader .= '--'.$this->textboundary."\r\n";
		$this->textheader .= 'Content-Type: text/html; charset="'.$this->charset.'"'."\r\n";
		$this->textheader .= 'Content-Transfer-Encoding: quoted-printable'."\r\n\r\n";
		$this->textheader .= '<html><body>'.$text.'</body></html>'."\r\n\r\n";
		$this->textheader .= '--'.$this->textboundary.'--'."\r\n\r\n";
	}

	function attachment($attachfile) {
		if(is_file($attachfile)) {
			$attachment_header = '--'.$this->emailboundary."\r\n" ;
			$attachment_header .= 'Content-Type: application/octet-stream; name="'.basename($attachfile).'"'."\r\n";
			$attachment_header .= 'Content-Transfer-Encoding: base64'."\r\n";
			$attachment_header .= 'Content-Disposition: attachment; filename="'.basename($attachfile).'"'."\r\n\r\n";
			$file['content'] = fread(fopen($attachfile,"rb"),filesize($attachfile));
			$file['content'] = base64_encode($file['content']);
			$file['content'] = chunk_split($file['content'],72);
			$this->attachment[] = $attachment_header.$file['content']."\r\n";
		}
		else {
			die("File doesn't exist'!");
		}
	}

	function send() {
		$this->makeMimeMail();
		$header = $this->emailheader;
		if(count($this->attachment)>0) {
			$header .= 'Content-Type: multipart/mixed; boundary="'.$this->emailboundary.'"'."\r\n\r\n";
			$header .= '--'.$this->emailboundary."\r\n";
			$header .= $this->textheader;
			if(count($this->attachment) > 0) $header .= implode("",$this->attachment);
			$header .= '--'.$this->emailboundary.'--';
		}
		else {
			$header .= $this->textheader;
		}
		$result = mail("$this->emailto",$this->emailsubject,"",$header);
		$this->deletememory();
		return $result;
	}

	function deletememory() {
		unset($this->emailheader);
		unset($this->textheader);
		unset($this->attachment);
	}
}
?>
see http://forum.cmsmadesimple.org/index.php/topic,487.0.html


This page in: English - Deutsch - Español - Français - Italiano - Lietuvių - Nederlands - Norsk - Polski - Česky - Русский - Svenska - Tiếng Việt - عربي - 日本語 简体中文

User Handbook/Admin Panel/Extensions/Tags

From CMSMS

(Redirected from Tags)
Arvixe - A CMSMS Partner