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

Have a question or a suggestion about a 3rd party addon module or plugin?
Let us know here.
Post Reply
beattie
Forum Members
Forum Members
Posts: 98
Joined: Sun Dec 21, 2008 11:35 pm

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

Post 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.
Last edited by Anonymous on Tue May 18, 2010 9:00 am, edited 1 time in total.
janb

Re: Separate Custom Fields in News Module Form Template?

Post 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
Last edited by janb on Sat May 15, 2010 10:34 am, edited 1 time in total.
beattie
Forum Members
Forum Members
Posts: 98
Joined: Sun Dec 21, 2008 11:35 pm

Re: Separate Custom Fields in News Module Form Template?

Post 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?..
janb

Re: Separate Custom Fields in News Module Form Template?

Post 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
Last edited by janb on Sat May 15, 2010 11:51 am, edited 1 time in total.
beattie
Forum Members
Forum Members
Posts: 98
Joined: Sun Dec 21, 2008 11:35 pm

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

Post 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;}
Last edited by Anonymous on Sat May 15, 2010 12:33 pm, edited 1 time in total.
beattie
Forum Members
Forum Members
Posts: 98
Joined: Sun Dec 21, 2008 11:35 pm

Re: Separate Custom Fields in Summary Template

Post 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?  ???
Last edited by Anonymous on Mon May 17, 2010 11:41 pm, edited 1 time in total.
beattie
Forum Members
Forum Members
Posts: 98
Joined: Sun Dec 21, 2008 11:35 pm

Re: Separate Custom Fields in News Module Form Template?

Post 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}
Post Reply

Return to “Modules/Add-Ons”