Page 1 of 1

[SOLVED] Separate Custom Fields in News Module Form Template?

Posted: Sat May 15, 2010 8:53 am
by beattie
I've created an Article Submit form using the News Module fesubmit action. I am using CMS Version 1.7.1.

I have one custom field called 'writer'. Everything is working fine except all the custom fields are showing up on the form, including those which I have created for another purpose and which I don't want to be shown. Does anyone know if there is a way to call specific custom fields and not all at once?

The code for the custom fields on the 'factory settings' of the form template is:

Code: Select all

{if isset($customfields)}
	   {foreach from=$customfields item='onefield'}
	      <div class="pageoverflow">
		<p class="pagetext">{$onefield->name}:</p>
		<p class="pageinput">{$onefield->field}</p>
	      </div>
	   {/foreach}
	{/if}
This shows all custom fields. I need to just show the custom field called 'writer'.

I would really appreciate any help.

Re: Separate Custom Fields in News Module Form Template?

Posted: Sat May 15, 2010 10:23 am
by janb
Hi

Show a list of all available custom fields with this at the end of the template

Code: Select all

{$customfields|@print_r}
Comment out the foreach loop and access the field you want.
{$customfields[0]->field} in the example corresponds to the first customfield

Code: Select all

	{if isset($customfields)}
{*
	   {foreach from=$customfields item='onefield'}
	      <div class="pageoverflow">
		<p class="pagetext">{$onefield->name}:</p>
		<p class="pageinput">{$onefield->field}</p>
	      </div>
	   {/foreach}
*}
	      <div class="pageoverflow">
		<p class="pagetext">{$customfields[0]->name}:</p>
		<p class="pageinput">{$customfields[0]->field}</p>
	      </div>

	{/if}
JanB

Re: Separate Custom Fields in News Module Form Template?

Posted: Sat May 15, 2010 10:47 am
by beattie
Awesome! that worked perfect, thanks so much for your help and quick response!!

By the way, sorry to be a pain, just one final thing I can't get right, do you know how to remove the Turn WYSIWYG on/off and tick box which is underneath the 'comment' box? I don't want the user to be able to use a WYSIWYG so I have set the Frontend wysiwyg preferences to 'none' in the admin global settings but the WYSIWYG tick box still shows up on the front end form. I'm guessing I might need to edit a php file?..

Re: Separate Custom Fields in News Module Form Template?

Posted: Sat May 15, 2010 11:36 am
by janb
Hmm, the only way i have found removing the wysiwyg checkbox (and the label) is via css (without changing php code, which is not so good idea causing broken module support)

The form template have no surrounding divs
You can surround the whole form with the news div or make a new, but i prefer using the news div keeping things under control.
Insert the div like this:

Code: Select all

{$startform}
<div id="news">
...
...
</div> {*EndTag for NewsDiv*}
{$endform}
At the end of "Module: News" CSS insert this:

Code: Select all

.pageinput label, .pageinput input[type=checkbox] {
display:none;
}
I don't think this will influence other news styling, but you have to take a close look :)

JanB

Re: SOLVED Separate Custom Fields in News Module Form Template?

Posted: Sat May 15, 2010 12:29 pm
by beattie
Thanks so so much! you are a legend  :)

This is what I used for the stylesheet:

Code: Select all

.removetick
input[type=checkbox] {
display:none;
}
label  {display:none;}

Re: Separate Custom Fields in Summary Template

Posted: Mon May 17, 2010 11:37 pm
by beattie
I am now also trying to display separate image custom fields in the News Summary Template and have found that the code above which worked for the Form Template doesn't work for the Summary Template. Have been around in circles trying to get it to work and I'm sure it's probably a simple variation of the above code. Please can you help?  ???

Re: Separate Custom Fields in News Module Form Template?

Posted: Mon May 17, 2010 11:50 pm
by beattie
Got it!!! This is how I got it to work:

Code: Select all

{foreach from=$entry->fields item='field'}
        {if $field->type == 'file'}
  {if $field->name == 'your-image-field-name'}
          <img src="{$entry->file_location}/{$field->value}"/>
                {/if}
   {/if}
  {/foreach}