• twitter image
  • facebook image
  • youtube image
  • linkedin image
Language: CMS made Simple Czech Site Zur deutschsprachigen Supportseite Site francophone Sitio en Castellano CMSMS - Magyarország CMSMS -  ???????
Pages: [1] 2
  Print  
Author Topic: Field definitions in News 2.6  (Read 2827 times)
0 Members and 1 Guest are viewing this topic.
ian72
New Member


Karma: 0
Offline Offline

Posts: 4


« on: 15 Nov 2007, 08:34 »

I'm a new user of CMSMS so go easy on me please!

I'm using News 2.6 and cannot get my custom field definitions to show up in the pages.

E.g I've added a field definition called Filename (set to public)
In my summary template I'm trying to call it like so
Code:
{$entry->filename}

but no show (I've tried Filename too).

Showing all page variables using
Code:
{$entry|print_r}
tells me the custom field is not in the list either!
Checking the database show the info and table data is being stored correctly.
I've cleared the cache too.

Anyone else had success adding field definitions? Can you show me too
Thanks in advance
Ian



Logged
streever
Power Poster
***

Karma: 2
Offline Offline

Posts: 296



WWW
« Reply #1 on: 15 Nov 2007, 20:07 »

Hi Ian,

that is surprising!

it works for me.

I wonder if this is a cache issue--OR--if you are calling the wrong template.

Please make sure you are calling the template that has that variable IN IT--and that the variable is within the {for each} commands!!

Can you post template here?

thanks
Logged

If I help you, please give good karma. If I'm rude, give me bad karma. I like to know where I balance out in the end Smiley.
ian72
New Member


Karma: 0
Offline Offline

Posts: 4


« Reply #2 on: 16 Nov 2007, 05:30 »

hi streever,

I've tried clearing the cache to no avail.
In field definitions, I have a one called ImageCaption which is a Text Area and set to public. In my article I have put some text into that area.

In the detail template I have the following (copied from the original template)
Code:
{if isset($entry->fields)}

  {foreach from=$entry->fields item='field'}

{$field->name}: {eval var=$field->value}
     <div class="NewsSummaryField">
        {if $field->type == 'file'}
          <img src="{$entry->file_location}/{$field->value}/>
        {else}
          {$field->name}:&nbsp;{eval var=$field->value}
        {/if}
     </div>
  {/foreach}
{/if}

If I add
Code:
{$fields|print_r}
to print the variables, its shows
Code:
1

Have also tried using
Code:
{$entry->imagecaption}
but that shows nothing either.
Any ideas?
Thanks
Ian
Logged
cyberman
Support Team
Power Poster
***

Karma: 150
Offline Offline

Posts: 8943


Reality.sys is corrupt. Reboot universe (Y/N)?


WWW
« Reply #3 on: 16 Nov 2007, 06:15 »

Showing all page variables

For that you can/should use the tag {get_template_vars}.
Logged

"2 hours of try and error can save 10 minutes of manual reading"
(2 Stunden Ausprobieren können Ihnen 10 Minuten Handbuchlesen ersparen)
------------------------------------------------------------------------------------
Für deutschsprachige Anwender / for german speaking users only
http://www.cmsmadesimple.de/ - deutschsprachige Support-Seite für CMS made simple
http://demo.cmsmadesimple.de/ - Informationen der CMSms-Musterinstallation in deutsch
http://wiki.cmsmadesimple.org/index.php/Main_Page/de - deutschsprachiges Wiki für CMS made simple
http://dev.cmsmadesimple.org/projects/german/ - deutsche Sprachdateien für CMS made simple
-----
http://themes.cmsmadesimple.org/Full_Themes.html - Templates für CMS made simple (engl.)
http://www.cmsmadesimple.org/apidoc/ - API für CMSms 1.x (engl.)
cyberman
Support Team
Power Poster
***

Karma: 150
Offline Offline

Posts: 8943


Reality.sys is corrupt. Reboot universe (Y/N)?


WWW
« Reply #4 on: 16 Nov 2007, 06:27 »

Have you made a look inside the sample summary template?

There must be something like this

Code:
{if isset($entry->fields)}
  {foreach from=$entry->fields item='field'}
     <div class="NewsSummaryField">
        {if $field->type == 'file'}
          <img src="{$entry->file_location}/{$field->value}/>
        {else}
          {$field->name}:&nbsp;{eval var=$field->value}
        {/if}
     </div>
  {/foreach}
{/if}

And your new field will be added automatically Smiley ...
Logged

"2 hours of try and error can save 10 minutes of manual reading"
(2 Stunden Ausprobieren können Ihnen 10 Minuten Handbuchlesen ersparen)
------------------------------------------------------------------------------------
Für deutschsprachige Anwender / for german speaking users only
http://www.cmsmadesimple.de/ - deutschsprachige Support-Seite für CMS made simple
http://demo.cmsmadesimple.de/ - Informationen der CMSms-Musterinstallation in deutsch
http://wiki.cmsmadesimple.org/index.php/Main_Page/de - deutschsprachiges Wiki für CMS made simple
http://dev.cmsmadesimple.org/projects/german/ - deutsche Sprachdateien für CMS made simple
-----
http://themes.cmsmadesimple.org/Full_Themes.html - Templates für CMS made simple (engl.)
http://www.cmsmadesimple.org/apidoc/ - API für CMSms 1.x (engl.)
ian72
New Member


Karma: 0
Offline Offline

Posts: 4


« Reply #5 on: 16 Nov 2007, 06:45 »

Yeah I did- it's exactly the same as I posted above!
Logged
cyberman
Support Team
Power Poster
***

Karma: 150
Offline Offline

Posts: 8943


Reality.sys is corrupt. Reboot universe (Y/N)?


WWW
« Reply #6 on: 16 Nov 2007, 07:01 »

Works for me - please look here (the last news line)

http://test.cmsmadesimple.de/
Logged

"2 hours of try and error can save 10 minutes of manual reading"
(2 Stunden Ausprobieren können Ihnen 10 Minuten Handbuchlesen ersparen)
------------------------------------------------------------------------------------
Für deutschsprachige Anwender / for german speaking users only
http://www.cmsmadesimple.de/ - deutschsprachige Support-Seite für CMS made simple
http://demo.cmsmadesimple.de/ - Informationen der CMSms-Musterinstallation in deutsch
http://wiki.cmsmadesimple.org/index.php/Main_Page/de - deutschsprachiges Wiki für CMS made simple
http://dev.cmsmadesimple.org/projects/german/ - deutsche Sprachdateien für CMS made simple
-----
http://themes.cmsmadesimple.org/Full_Themes.html - Templates für CMS made simple (engl.)
http://www.cmsmadesimple.org/apidoc/ - API für CMSms 1.x (engl.)
ian72
New Member


Karma: 0
Offline Offline

Posts: 4


« Reply #7 on: 16 Nov 2007, 07:14 »

I've just changed the config file to run in debug mode and I see this
Code:
Error (1146): Table 'website.cms_module_news_fieldvals' doesn't exist

My table has no prefix and  is callled
Code:
website.module_news_fieldvals

Having looked at the action.default.php I can see an error on line 280.

Code:
//
    // Handle the custom fields
    //
    $query3 = 'SELECT A.value,B.id,B.name,B.type FROM cms_module_news_fieldvals A, cms_module_news_fielddefs B WHERE A.fielddef_id = B.id AND B.public = 1 AND A.news_id = ? ORDER BY B.item_order';

I've changed it to:

Code:
//
    // Handle the custom fields
    //
    $query3 = 'SELECT A.value,B.id,B.name,B.type FROM '.cms_db_prefix().'module_news_fieldvals A, '.cms_db_prefix().'module_news_fielddefs B WHERE A.fielddef_id = B.id AND B.public = 1 AND A.news_id = ? ORDER BY B.item_order';


and all is now working.

Hope this helps someone else.
Thanks for your replies.



Logged
carasmo
Forum Members
**

Karma: 5
Offline Offline

Posts: 193



WWW
« Reply #8 on: 17 Nov 2007, 11:17 »

I've looked high and low for instructions on field definitions and I can't find anything except for some forum posts and I can't follow them since they appear to start somewhere in the middle.

I want to add a thumbnail image to the summary  and a larger image to the detail page. They may or may not be used, but it's good to have on hand. Is there a step by step instruction for people who are not technically adept. I'm not able to intuit this.

Thanks!
Logged
calguy1000
CMS GURU - 2nd Tier Support.
Dev Team Member
Power Poster
*****

Karma: 162
Offline Offline

Posts: 5108

Gravatar

Second Tier support


WWW
« Reply #9 on: 17 Nov 2007, 11:35 »

1.  Go to the field definitions tab in News
     Create a new field definition called 'thumbnail' of type "file"
     Create another field definition called 'image' of type "file"

2. Go into the 'summary templates tab'
    Click 'add a new template'
    add:   {if isset($entry->thumbnail)}<img src="{$entry->file_location}/{$entry->thumbnail}"/>{/if}
    Give the new template a name
    Click submit

3.  Mark that template as default

4.  Go into the 'detail templates' tab
     Click 'add a new template'
     add:  {if isset($entry->thumbnail)}<img src="{$entry->file_location}/{$entry->image}"/>{/if}
     Give the new template a name
     Click submit

5.  Mark that template as default

6.  Add a couple of news articles with thumbnails and/or images for testing.

Now somewhere in your page template or page content, you should have a {news} tag.  If all worked well, you should see the thumbnail image in the summary view, and the full sized image in the detail view.  If not, do a view source on the output and make sure that the syntax is correct, I may have a typo in the above text.  If I do, you'll need to go back to the news admin and edit the templates that you created in the above steps.

You'll also want to add a <div> around each of the images, or a classname on the tag, set widths, alt tags, etc, etc, etc.
Logged

Follow me on twitter
For quality help follow these instructions:
a) Think about the problem for an hour
b) research the problem for an hour
c) spend 1/2 an hour explaining it and providing as much information as you can muster
(too much information is okay, not enough information may get your question ignored).
--
if you can't bother explaining your problem well, why should we bother helping with it.
----------------
Don't make me angry..... you won't like me when I'm angry....
carasmo
Forum Members
**

Karma: 5
Offline Offline

Posts: 193



WWW
« Reply #10 on: 17 Nov 2007, 11:51 »

YOU are the rocking-est ever! Thank you deeply and profoundly!
Logged
carasmo
Forum Members
**

Karma: 5
Offline Offline

Posts: 193



WWW
« Reply #11 on: 17 Nov 2007, 12:58 »

I followed it exactly and it didn't work. But I do get this at the top of the news entry page:

Invalid argument supplied for foreach() in /home/.scoundrel/domainuser/domain.com/modules/News/action.editarticle.php on line 141

141-168 looks like this:

Code:

foreach( $types as $onetype )
  {
$elem = $id.'customfield_'.$onetype['id'];
if( isset($_FILES[$elem]) &&
$_FILES[$elem]['name'] != '' )
  {
if( $_FILES[$elem]['error'] != 0 ||
$_FILES[$elem]['tmp_name'] == '')
  {
echo $this->ShowErrors($this->Lang('error_upload'));
$error = true;
  }
else
  {
$error = '';
$value = $this->handle_upload($articleid,$elem,$error);
if( $value === FALSE )
  {
echo $this->ShowErrors($error);
$error = true;
  }
else
  {
$params['customfield'][$onetype['id']] = $value;
  }
  }
  }
  }


Logged
Roberto
Forum Members
**

Karma: 0
Offline Offline

Posts: 24



WWW
« Reply #12 on: 20 Nov 2007, 07:36 »

Hello carasmo,

I've the same warning, maybe this module doesn't work correctly using fields definition.

Have you eliminated this warning?

Roberto.
Logged
carasmo
Forum Members
**

Karma: 5
Offline Offline

Posts: 193



WWW
« Reply #13 on: 20 Nov 2007, 10:36 »

I can't figure it out.  Cry
Logged
dmccay
Guest
« Reply #14 on: 01 Dec 2007, 07:39 »

I followed it exactly and it didn't work. But I do get this at the top of the news entry page:

Invalid argument supplied for foreach() in /home/.scoundrel/domainuser/domain.com/modules/News/action.editarticle.php on line 141

141-168 looks like this:

Code:

foreach( $types as $onetype )
  {
$elem = $id.'customfield_'.$onetype['id'];
if( isset($_FILES[$elem]) &&
$_FILES[$elem]['name'] != '' )
  {
if( $_FILES[$elem]['error'] != 0 ||
$_FILES[$elem]['tmp_name'] == '')
  {
echo $this->ShowErrors($this->Lang('error_upload'));
$error = true;
  }
else
  {
$error = '';
$value = $this->handle_upload($articleid,$elem,$error);
if( $value === FALSE )
  {
echo $this->ShowErrors($error);
$error = true;
  }
else
  {
f $params['customfield'][$onetype['id']] = $value;
  }
  }
  }
  }



Had the same issue and solved it by testing the $types array to see if it was empty.
This is a common problem in PHP so all you have to do is open the file called 'action.editarticle.php' and make the following changes.
Right before the line
Code:
foreach( $types as $onetype )
add the statement
Code:
if($types != 0){
and after the last closing bracket ADD another one to close out the If Statement.
The whole section should then look like this:
Code:
                     if($types != 0){
foreach( $types as $onetype )
  {
$elem = $id.'customfield_'.$onetype['id'];
if( isset($_FILES[$elem]) &&
$_FILES[$elem]['name'] != '' )
  {
if( $_FILES[$elem]['error'] != 0 ||
$_FILES[$elem]['tmp_name'] == '')
  {
echo $this->ShowErrors($this->Lang('error_upload'));
$error = true;
  }
else
  {
$error = '';
$value = $this->handle_upload($articleid,$elem,$error);
if( $value === FALSE )
  {
echo $this->ShowErrors($error);
$error = true;
  }
else
  {
$params['customfield'][$onetype['id']] = $value;
  }
  }
  }
    }
}
Logged
Pages: [1] 2
  Print  
 
Jump to: