Removing fields in Guestbook module.

Talk about writing modules and plugins for CMS Made Simple, or about specific core functionality. This board is for PHP programmers that are contributing to CMSMS not for site developers
Post Reply
dec

Removing fields in Guestbook module.

Post by dec »

Core 0.13, newest Guestbook module.

Should be relatively straightforward, trying to remove the country, location and homepage fields in the entry form. After properly (or not so) removing it from the code it shows the success screen but when I return to the guestbook index then it doesn't. I don't code PHP therefore reading it was painful enough for me :) I'm guessing its a field count boolean somewhere that doesn't return true. Any suggestions?

Thanks in advance,
Andrus
Dee
Power Poster
Power Poster
Posts: 1197
Joined: Sun Mar 19, 2006 8:46 pm
Location: the Netherlands

Re: Removing fields in Guestbook module.

Post by Dee »

Without any PHP knowledge I don't think you'll be able to get rid of those fields as it would require quite a lot of changes to both the form creation and the SQL commands related to the modules_guestbook table.

Maybe some day someone will make the guestbook module's entry fields more configurable (kinda like formbuilder, maybe using SjG's new "Module Lightweight Form API" module, http://dev.cmsmadesimple.org/scm/?group_id=219), but I don't think I will have the time to do so in the near future.
User avatar
Dr.CSS
Moderator
Moderator
Posts: 12711
Joined: Thu Mar 09, 2006 5:32 am
Location: Arizona

Re: Removing fields in Guestbook module.

Post by Dr.CSS »

If you look in the 'view source' of the rendered page with the form on it you may find some classes that you can use 'display: none' on.
Geo
Forum Members
Forum Members
Posts: 24
Joined: Mon Apr 11, 2005 2:46 pm

Re: Removing fields in Guestbook module.

Post by Geo »

turning all the fields you *dont* want to "hidden" and deleting the "$title.xxx" allows you to remove fields you dont want in a none destructive way.  to tidy up the layout on the new "post" section i then just removed the additional table markers.

heres my sample amended code removing all but the "name" and "post" fields:

Code: Select all

<!-- Frontend Guestbook Entry Form //-->
<div class="cms-guestbook-div-insert">
	<form name="insert" action="{$geturl}" method="post">
	<input type="hidden" name="uid" value="{$uid}" />
		<table>
			<tr>
				<td>{$titles.sender}(*):</td>
				<td><input type="text" name="sender" value="{$values.sender}" /></td>

				
			<td><input type="hidden" name="country" value="{$values.country}" /></td>

				
				<td><input type="hidden" name="location" value="{$values.location}" /></td>

				
				<td><input type="hidden" name="e_mail" value="{$values.e_mail}" /></td>

				
				<td><input type="hidden" name="homepage" value="{$values.homepage}" /></td>
			</tr>
			<tr>
				<td>{$titles.chars_remaining}:</td>
				<td>
					<__script__ type="text/javascript">
					<!--
{literal}
					function addEvent(elm, evType, fn, useCapture) 
					// cross-browser event handling for IE5+, NS6+ and Mozilla/Gecko
					// by Scott Andrew
					{
						if (elm.addEventListener) {
							elm.addEventListener(evType, fn, useCapture);
							return true;
						} else if (elm.attachEvent) {
							var r = elm.attachEvent('on' + evType, fn);
						} else {
							elm['on' + evType] = fn;
						}
					}
{/literal}
{if $wysiwyg}
{literal}
					function FCKeditor_OnComplete(editorInstance) {
						addEvent(editorInstance.EditorDocument, 'keyup', checkLen, false);
					}
{/literal}
{/if}
{if !$wysiwyg}
{literal}
					function addListeners() {
						var messageinput = document.getElementById('message');
						addEvent(messageinput, 'keyup', checkLen, false);
					}
{/literal}
{/if}
{literal}
					function checkLen() {
{/literal}
						maxLen="{$max_textleng}";
//						sTooLong = 'Insert maximal ' + maxLen + ' characters!';
						sTooLong = "{$toolong}";
{if $wysiwyg}
{literal}
						var oEditor = FCKeditorAPI.GetInstance('message');
						var oDOM = oEditor.EditorDocument;
						var iLength; 
						
						if (document.all) // Internet Explorer. 
						{ 
							iLength = oDOM.body.innerText.length; 
						} 
						else // Gecko. 
						{ 
							var r = oDOM.createRange(); 
							r.selectNodeContents(oDOM.body); 
							iLength = r.toString().length; 
						}
						 
						if(iLength>maxLen)
						{
							oDOM.body.innerHTML = oEditor.GetXHTML(false).substring(0,oEditor.GetXHTML(false).length-1);
							alert(sTooLong);
						}
						else
						{
							document.insert.counter.value=maxLen-iLength;
						}
{/literal}
{else}
{literal}
						var txt=document.insert.message.value;
						if(txt.length>maxLen)
						{
							alert(sTooLong);
							document.insert.message.value=txt.substring(0,maxLen);
							document.insert.counter.value=0;
						}
						else
						{
							document.insert.counter.value=maxLen-txt.length;
						}
{/literal}
{/if}
{literal}
					}
{/literal}
{if !$wysiwyg}
					addEvent(window, 'load', addListeners, false);
{/if}
					//-->
					</__script>
					<input type="text" name="counter" value="{$counter}" size="4" />
				</td>
			</tr>
			<tr>
				<td>{$titles.message}(*)</td>
				<td>
{if $wysiwyg}
				{$wysiwyg}
{else}
					<textarea name="message" id="message" rows="10" cols="40">{$values.message}</textarea> 
{/if}
				</td>
			</tr>
{if $show_captcha}
			<tr>
				<td colspan="2" align="center">
					{$titles.captcha}: <input type="text" name="captcha_phrase" /><br />
					{$captcha}
				</td>
			</tr>
{/if}
			<tr>
				<td colspan="2" align="center">
					<input type="submit" name="submitted" value="{$labels.insert}"> <input type="submit" name="cancel" value="{$labels.cancel}" />
				</td>
			</tr>
		</table>
	</form>
</div>
Geo.
tobik
Translator
Translator
Posts: 149
Joined: Thu Aug 16, 2007 6:18 pm

Re: Removing fields in Guestbook module.

Post by tobik »

With the latest SVN guestbook version you may also remove the fields altogether from the html form.
Post Reply

Return to “Developers Discussion”