• twitter image
  • facebook image
  • youtube image
  • linkedin image
Language: CMS Made Simple Czech CMS Made Simple France CMS Made Simple Spain CMS Made Simple Hungary CMS Made Simple Russia CMS Made Simple Netherlands

All times are UTC




Post new topic Reply to topic  [ 17 posts ]  Go to page 1, 2  Next
Author Message
 Post subject: Field definitions in News 2.6
PostPosted: Thu Nov 15, 2007 1:34 pm 
Offline
New Member

Joined: Thu Nov 15, 2007 1:16 pm
Posts: 4
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


Top
 Profile  
 
 Post subject: Re: Field definitions in News 2.6
PostPosted: Fri Nov 16, 2007 1:07 am 
Offline
Power Poster
Power Poster
User avatar

Joined: Fri May 05, 2006 7:55 pm
Posts: 293
Location: New Haven, CT
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

_________________
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 :).


Top
 Profile  
 
 Post subject: Re: Field definitions in News 2.6
PostPosted: Fri Nov 16, 2007 10:30 am 
Offline
New Member

Joined: Thu Nov 15, 2007 1:16 pm
Posts: 4
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}: {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


Top
 Profile  
 
 Post subject: Re: Field definitions in News 2.6
PostPosted: Fri Nov 16, 2007 11:15 am 
ian72 wrote:
Showing all page variables


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


Top
  
 
 Post subject: Re: Field definitions in News 2.6
PostPosted: Fri Nov 16, 2007 11:27 am 
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}: {eval var=$field->value}
        {/if}
     </div>
  {/foreach}
{/if}


And your new field will be added automatically :) ...


Top
  
 
 Post subject: Re: Field definitions in News 2.6
PostPosted: Fri Nov 16, 2007 11:45 am 
Offline
New Member

Joined: Thu Nov 15, 2007 1:16 pm
Posts: 4
Yeah I did- it's exactly the same as I posted above!


Top
 Profile  
 
 Post subject: Re: Field definitions in News 2.6
PostPosted: Fri Nov 16, 2007 12:01 pm 
Works for me - please look here (the last news line)

http://test.cmsmadesimple.de/


Top
  
 
 Post subject: [RESOLVED]: Field definitions in News 2.6
PostPosted: Fri Nov 16, 2007 12:14 pm 
Offline
New Member

Joined: Thu Nov 15, 2007 1:16 pm
Posts: 4
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.


Top
 Profile  
 
 Post subject: Re: Field definitions in News 2.6
PostPosted: Sat Nov 17, 2007 4:17 pm 
Offline
Power Poster
Power Poster
User avatar

Joined: Thu Feb 08, 2007 6:11 pm
Posts: 292
Location: Florida
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!


Top
 Profile  
 
 Post subject: Re: Field definitions in News 2.6
PostPosted: Sat Nov 17, 2007 4:35 pm 
Offline
Dev Team Member
Dev Team Member
User avatar

Joined: Tue Oct 19, 2004 6:44 pm
Posts: 5828
Location: Fernie British Columbia, Canada
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)}{/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)}{/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
around each of the images, or a classname on the tag, set widths, alt tags, etc, etc, etc.

_________________
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....


Top
 Profile  
 
 Post subject: Re: Field definitions in News 2.6
PostPosted: Sat Nov 17, 2007 4:51 pm 
Offline
Power Poster
Power Poster
User avatar

Joined: Thu Feb 08, 2007 6:11 pm
Posts: 292
Location: Florida
YOU are the rocking-est ever! Thank you deeply and profoundly!


Top
 Profile  
 
 Post subject: Re: Field definitions in News 2.6
PostPosted: Sat Nov 17, 2007 5:58 pm 
Offline
Power Poster
Power Poster
User avatar

Joined: Thu Feb 08, 2007 6:11 pm
Posts: 292
Location: Florida
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;
                    }
                 }
              }
           }




Top
 Profile  
 
 Post subject: Re: Field definitions in News 2.6
PostPosted: Tue Nov 20, 2007 12:36 pm 
Offline
Forum Members
Forum Members
User avatar

Joined: Thu Oct 25, 2007 6:37 pm
Posts: 24
Location: Sevilla - Andalucía
Hello carasmo,

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

Have you eliminated this warning?

Roberto.


Top
 Profile  
 
 Post subject: Re: Field definitions in News 2.6
PostPosted: Tue Nov 20, 2007 3:36 pm 
Offline
Power Poster
Power Poster
User avatar

Joined: Thu Feb 08, 2007 6:11 pm
Posts: 292
Location: Florida
I can't figure it out.  :'(


Top
 Profile  
 
 Post subject: SOLVED Re: Field definitions in News 2.6
PostPosted: Sat Dec 01, 2007 12:39 pm 
carasmo wrote:
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;
                    }
                 }
              }
             }
         }


Top
  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 17 posts ]  Go to page 1, 2  Next

All times are UTC


Who is online

Users browsing this forum: olumide


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Arvixe - A CMSMS Partner