The following warnings occurred:
Warning [2] Undefined array key "avatartype" - Line: 783 - File: global.php PHP 8.1.27 (Linux)
File Line Function
/global.php 783 errorHandler->error
/showthread.php 26 require_once
Warning [2] Undefined array key "avatartype" - Line: 783 - File: global.php PHP 8.1.27 (Linux)
File Line Function
/global.php 783 errorHandler->error
/showthread.php 26 require_once
Warning [2] Undefined variable $newpmmsg - Line: 40 - File: global.php(841) : eval()'d code PHP 8.1.27 (Linux)
File Line Function
/global.php(841) : eval()'d code 40 errorHandler->error
/global.php 841 eval
/showthread.php 26 require_once
Warning [2] Undefined array key "style" - Line: 909 - File: global.php PHP 8.1.27 (Linux)
File Line Function
/global.php 909 errorHandler->error
/showthread.php 26 require_once
Warning [2] Undefined property: MyLanguage::$lang_select_default - Line: 5024 - File: inc/functions.php PHP 8.1.27 (Linux)
File Line Function
/inc/functions.php 5024 errorHandler->error
/global.php 909 build_theme_select
/showthread.php 26 require_once
Warning [2] Undefined array key "additionalgroups" - Line: 7162 - File: inc/functions.php PHP 8.1.27 (Linux)
File Line Function
/inc/functions.php 7162 errorHandler->error
/inc/functions.php 5044 is_member
/global.php 909 build_theme_select
/showthread.php 26 require_once
Warning [2] Undefined array key 1 - Line: 1415 - File: inc/functions.php PHP 8.1.27 (Linux)
File Line Function
/inc/functions.php 1415 errorHandler->error
/inc/functions.php 1370 fetch_forum_permissions
/showthread.php 137 forum_permissions
Warning [2] Undefined array key 1 - Line: 1415 - File: inc/functions.php PHP 8.1.27 (Linux)
File Line Function
/inc/functions.php 1415 errorHandler->error
/inc/functions.php 1380 fetch_forum_permissions
/inc/functions.php 2909 forum_permissions
/showthread.php 621 build_forum_jump
Warning [2] Undefined array key 1 - Line: 1415 - File: inc/functions.php PHP 8.1.27 (Linux)
File Line Function
/inc/functions.php 1415 errorHandler->error
/inc/functions.php 1380 fetch_forum_permissions
/inc/functions.php 2909 forum_permissions
/showthread.php 621 build_forum_jump
Warning [2] Undefined array key 1 - Line: 1415 - File: inc/functions.php PHP 8.1.27 (Linux)
File Line Function
/inc/functions.php 1415 errorHandler->error
/inc/functions.php 1380 fetch_forum_permissions
/inc/functions.php 2909 forum_permissions
/showthread.php 621 build_forum_jump
Warning [2] Undefined array key 1 - Line: 1415 - File: inc/functions.php PHP 8.1.27 (Linux)
File Line Function
/inc/functions.php 1415 errorHandler->error
/inc/functions.php 1380 fetch_forum_permissions
/inc/functions.php 2909 forum_permissions
/showthread.php 621 build_forum_jump
Warning [2] Undefined array key 1 - Line: 1415 - File: inc/functions.php PHP 8.1.27 (Linux)
File Line Function
/inc/functions.php 1415 errorHandler->error
/inc/functions.php 1380 fetch_forum_permissions
/inc/functions.php 2909 forum_permissions
/showthread.php 621 build_forum_jump
Warning [2] Undefined array key 1 - Line: 1415 - File: inc/functions.php PHP 8.1.27 (Linux)
File Line Function
/inc/functions.php 1415 errorHandler->error
/inc/functions.php 1380 fetch_forum_permissions
/inc/functions.php 2909 forum_permissions
/showthread.php 621 build_forum_jump
Warning [2] Undefined array key "mybb" - Line: 1952 - File: inc/functions.php PHP 8.1.27 (Linux)
File Line Function
/inc/functions.php 1952 errorHandler->error
/inc/functions_indicators.php 41 my_set_array_cookie
/showthread.php 629 mark_thread_read
Warning [2] Undefined property: MyLanguage::$ratings_update_error - Line: 5 - File: showthread.php(732) : eval()'d code PHP 8.1.27 (Linux)
File Line Function
/showthread.php(732) : eval()'d code 5 errorHandler->error
/showthread.php 732 eval
Warning [2] Undefined array key "additionalgroups" - Line: 7162 - File: inc/functions.php PHP 8.1.27 (Linux)
File Line Function
/inc/functions.php 7162 errorHandler->error
/inc/functions_user.php 844 is_member
/inc/functions_post.php 406 purgespammer_show
/showthread.php 1070 build_postbit
Warning [2] Undefined array key "profilefield" - Line: 6 - File: inc/functions_post.php(474) : eval()'d code PHP 8.1.27 (Linux)
File Line Function
/inc/functions_post.php(474) : eval()'d code 6 errorHandler->error
/inc/functions_post.php 474 eval
/showthread.php 1070 build_postbit
Warning [2] Undefined array key "canonlyreplyownthreads" - Line: 660 - File: inc/functions_post.php PHP 8.1.27 (Linux)
File Line Function
/inc/functions_post.php 660 errorHandler->error
/showthread.php 1070 build_postbit
Warning [2] Undefined array key "showimages" - Line: 741 - File: inc/functions_post.php PHP 8.1.27 (Linux)
File Line Function
/inc/functions_post.php 741 errorHandler->error
/showthread.php 1070 build_postbit
Warning [2] Undefined array key "showvideos" - Line: 746 - File: inc/functions_post.php PHP 8.1.27 (Linux)
File Line Function
/inc/functions_post.php 746 errorHandler->error
/showthread.php 1070 build_postbit
Warning [2] Undefined array key "additionalgroups" - Line: 7162 - File: inc/functions.php PHP 8.1.27 (Linux)
File Line Function
/inc/functions.php 7162 errorHandler->error
/inc/functions_user.php 844 is_member
/inc/functions_post.php 406 purgespammer_show
/showthread.php 1070 build_postbit
Warning [2] Undefined array key "profilefield" - Line: 6 - File: inc/functions_post.php(474) : eval()'d code PHP 8.1.27 (Linux)
File Line Function
/inc/functions_post.php(474) : eval()'d code 6 errorHandler->error
/inc/functions_post.php 474 eval
/showthread.php 1070 build_postbit
Warning [2] Undefined array key "canonlyreplyownthreads" - Line: 660 - File: inc/functions_post.php PHP 8.1.27 (Linux)
File Line Function
/inc/functions_post.php 660 errorHandler->error
/showthread.php 1070 build_postbit
Warning [2] Undefined array key "showimages" - Line: 741 - File: inc/functions_post.php PHP 8.1.27 (Linux)
File Line Function
/inc/functions_post.php 741 errorHandler->error
/showthread.php 1070 build_postbit
Warning [2] Undefined array key "showvideos" - Line: 746 - File: inc/functions_post.php PHP 8.1.27 (Linux)
File Line Function
/inc/functions_post.php 746 errorHandler->error
/showthread.php 1070 build_postbit
Warning [2] Undefined array key "additionalgroups" - Line: 7162 - File: inc/functions.php PHP 8.1.27 (Linux)
File Line Function
/inc/functions.php 7162 errorHandler->error
/inc/functions_user.php 844 is_member
/inc/functions_post.php 406 purgespammer_show
/showthread.php 1070 build_postbit
Warning [2] Undefined array key "profilefield" - Line: 6 - File: inc/functions_post.php(474) : eval()'d code PHP 8.1.27 (Linux)
File Line Function
/inc/functions_post.php(474) : eval()'d code 6 errorHandler->error
/inc/functions_post.php 474 eval
/showthread.php 1070 build_postbit
Warning [2] Undefined array key "canonlyreplyownthreads" - Line: 660 - File: inc/functions_post.php PHP 8.1.27 (Linux)
File Line Function
/inc/functions_post.php 660 errorHandler->error
/showthread.php 1070 build_postbit
Warning [2] Undefined array key "showimages" - Line: 741 - File: inc/functions_post.php PHP 8.1.27 (Linux)
File Line Function
/inc/functions_post.php 741 errorHandler->error
/showthread.php 1070 build_postbit
Warning [2] Undefined array key "showvideos" - Line: 746 - File: inc/functions_post.php PHP 8.1.27 (Linux)
File Line Function
/inc/functions_post.php 746 errorHandler->error
/showthread.php 1070 build_postbit
Warning [2] Undefined array key "additionalgroups" - Line: 7162 - File: inc/functions.php PHP 8.1.27 (Linux)
File Line Function
/inc/functions.php 7162 errorHandler->error
/inc/functions_user.php 844 is_member
/inc/functions_post.php 406 purgespammer_show
/showthread.php 1070 build_postbit
Warning [2] Undefined array key "profilefield" - Line: 6 - File: inc/functions_post.php(474) : eval()'d code PHP 8.1.27 (Linux)
File Line Function
/inc/functions_post.php(474) : eval()'d code 6 errorHandler->error
/inc/functions_post.php 474 eval
/showthread.php 1070 build_postbit
Warning [2] Undefined array key "canonlyreplyownthreads" - Line: 660 - File: inc/functions_post.php PHP 8.1.27 (Linux)
File Line Function
/inc/functions_post.php 660 errorHandler->error
/showthread.php 1070 build_postbit
Warning [2] Undefined array key "showimages" - Line: 741 - File: inc/functions_post.php PHP 8.1.27 (Linux)
File Line Function
/inc/functions_post.php 741 errorHandler->error
/showthread.php 1070 build_postbit
Warning [2] Undefined array key "showvideos" - Line: 746 - File: inc/functions_post.php PHP 8.1.27 (Linux)
File Line Function
/inc/functions_post.php 746 errorHandler->error
/showthread.php 1070 build_postbit
Warning [2] Undefined array key "additionalgroups" - Line: 7162 - File: inc/functions.php PHP 8.1.27 (Linux)
File Line Function
/inc/functions.php 7162 errorHandler->error
/inc/functions_user.php 844 is_member
/inc/functions_post.php 406 purgespammer_show
/showthread.php 1070 build_postbit
Warning [2] Undefined array key "profilefield" - Line: 6 - File: inc/functions_post.php(474) : eval()'d code PHP 8.1.27 (Linux)
File Line Function
/inc/functions_post.php(474) : eval()'d code 6 errorHandler->error
/inc/functions_post.php 474 eval
/showthread.php 1070 build_postbit
Warning [2] Undefined array key "canonlyreplyownthreads" - Line: 660 - File: inc/functions_post.php PHP 8.1.27 (Linux)
File Line Function
/inc/functions_post.php 660 errorHandler->error
/showthread.php 1070 build_postbit
Warning [2] Undefined array key "showimages" - Line: 741 - File: inc/functions_post.php PHP 8.1.27 (Linux)
File Line Function
/inc/functions_post.php 741 errorHandler->error
/showthread.php 1070 build_postbit
Warning [2] Undefined array key "showvideos" - Line: 746 - File: inc/functions_post.php PHP 8.1.27 (Linux)
File Line Function
/inc/functions_post.php 746 errorHandler->error
/showthread.php 1070 build_postbit
Warning [2] Undefined array key "additionalgroups" - Line: 7162 - File: inc/functions.php PHP 8.1.27 (Linux)
File Line Function
/inc/functions.php 7162 errorHandler->error
/inc/functions_user.php 844 is_member
/inc/functions_post.php 406 purgespammer_show
/showthread.php 1070 build_postbit
Warning [2] Undefined array key "profilefield" - Line: 6 - File: inc/functions_post.php(474) : eval()'d code PHP 8.1.27 (Linux)
File Line Function
/inc/functions_post.php(474) : eval()'d code 6 errorHandler->error
/inc/functions_post.php 474 eval
/showthread.php 1070 build_postbit
Warning [2] Undefined array key "canonlyreplyownthreads" - Line: 660 - File: inc/functions_post.php PHP 8.1.27 (Linux)
File Line Function
/inc/functions_post.php 660 errorHandler->error
/showthread.php 1070 build_postbit
Warning [2] Undefined array key "showimages" - Line: 741 - File: inc/functions_post.php PHP 8.1.27 (Linux)
File Line Function
/inc/functions_post.php 741 errorHandler->error
/showthread.php 1070 build_postbit
Warning [2] Undefined array key "showvideos" - Line: 746 - File: inc/functions_post.php PHP 8.1.27 (Linux)
File Line Function
/inc/functions_post.php 746 errorHandler->error
/showthread.php 1070 build_postbit
Warning [2] Undefined array key "additionalgroups" - Line: 7162 - File: inc/functions.php PHP 8.1.27 (Linux)
File Line Function
/inc/functions.php 7162 errorHandler->error
/inc/functions_user.php 844 is_member
/inc/functions_post.php 406 purgespammer_show
/showthread.php 1070 build_postbit
Warning [2] Undefined array key "profilefield" - Line: 6 - File: inc/functions_post.php(474) : eval()'d code PHP 8.1.27 (Linux)
File Line Function
/inc/functions_post.php(474) : eval()'d code 6 errorHandler->error
/inc/functions_post.php 474 eval
/showthread.php 1070 build_postbit
Warning [2] Undefined array key "canonlyreplyownthreads" - Line: 660 - File: inc/functions_post.php PHP 8.1.27 (Linux)
File Line Function
/inc/functions_post.php 660 errorHandler->error
/showthread.php 1070 build_postbit
Warning [2] Undefined array key "showimages" - Line: 741 - File: inc/functions_post.php PHP 8.1.27 (Linux)
File Line Function
/inc/functions_post.php 741 errorHandler->error
/showthread.php 1070 build_postbit
Warning [2] Undefined array key "showvideos" - Line: 746 - File: inc/functions_post.php PHP 8.1.27 (Linux)
File Line Function
/inc/functions_post.php 746 errorHandler->error
/showthread.php 1070 build_postbit
Warning [2] Undefined array key "invisible" - Line: 1506 - File: showthread.php PHP 8.1.27 (Linux)
File Line Function
/showthread.php 1506 errorHandler->error
Warning [2] Undefined variable $threadnotesbox - Line: 30 - File: showthread.php(1533) : eval()'d code PHP 8.1.27 (Linux)
File Line Function
/showthread.php(1533) : eval()'d code 30 errorHandler->error
/showthread.php 1533 eval
Warning [2] Undefined variable $addremovesubscription - Line: 79 - File: showthread.php(1533) : eval()'d code PHP 8.1.27 (Linux)
File Line Function
/showthread.php(1533) : eval()'d code 79 errorHandler->error
/showthread.php 1533 eval



FORUMS


The Form Tools forums are no longer active, but the old posts have been archived here. Please see the Help page on how to get help / report issues.

Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Foreach or not foreach ? - smarty template
#1
Question 
Hello,
everyday I'm better in Form Tools coding and formatting, but here is the problem I can't handle.
I need to print specific output of submissions (one submission per page). "Additional text here" is not a part of field title and I need to be able to change it in different views. I made new export type and I'm trying to change smarty template to work for me. Here is my code:

Code:
{* loop through all submissions in the current result set *}
{foreach from=$submissions item=submission name=row}
  
<table cellpadding="2" cellspacing="0" width="610" class="print_table2">
  
  {* loop through all submissions in the current View *}
  {foreach from=$display_fields item=field name=col_row}
    {assign var=field_id value=$field.field_id}
    {assign var=field_type value=$field.field_info.field_type}
    {assign var=col_name value=$field.col_name}
    {assign var=value value=$submission.$col_name}
  {if $col_name == "country"}
  {smart_display_field_values field_id=$field_id  selected=$submission.country}{/if}
{/foreach}
<tr>
      <td width="243" valign="top">Last name (additional text here)</td>
      <td width="347" class="big">{$submission.last_name}</td>
    </tr>
    <tr>
      <td valign="top">Name (additional text here)</td>
      <td class="big">{$submission.name}</td>
    </tr>
    <tr>
      <td valign="top">Country (additional text here)</td>
      <td class="big">{$submission.country}</td>
    </tr>
    <tr>
      <td valign="top">Client number (additional text here)</td>
      <td class="big">{$submission.client_number}</td>
    </tr>
  </table>
  

{if !$smarty.foreach.row.last}
  <br />
  <div class="no_print"><i>- {$LANG.phrase_new_page} -</i></div>
  <br class="page_break" />
{/if}

{/foreach}

1. The field "country" is dropdown field type and I need it to show selected option display text not field value. I know it has something to do with function.smart_display_field_values.php, but how to do it?
The code:

Code:
{if $col_name == "country"}
  {smart_display_field_values field_id=$field_id  selected=$submission.country}{/if}

does display it correctly, but only positioned in "foreach" function, but I need it between <td> tags.

2. The field "client number" is field from clients table stored with each submission in submissions table. Could I somehow include in this output additional fields from clients "on the fly" (I suppose the right expression is "from session" Smile ) or it should be better to store them in submission table?
Administrator doesn't need this output, just clients, so maybe it could be done?

Thanks for any help!
Lina
Reply
#2
Hi Lina,

Great questions!

So for the first one, how about just moving the foreach block into the appropriate spot (within the <td></td>)? If it's outputting it properly, would that work? Try this:

Code:
{* loop through all submissions in the current result set *}
{foreach from=$submissions item=submission name=row}
  
  <table cellpadding="2" cellspacing="0" width="610" class="print_table2">
    <tr>
      <td width="243" valign="top">Last name (additional text here)</td>
      <td width="347" class="big">{$submission.last_name}</td>
    </tr>
    <tr>
      <td valign="top">Name (additional text here)</td>
      <td class="big">{$submission.name}</td>
    </tr>
    <tr>
      <td valign="top">Country (additional text here)</td>
      <td class="big">
        {foreach from=$display_fields item=field name=col_row}
          {assign var=field_id value=$field.field_id}
          {assign var=field_type value=$field.field_info.field_type}
          {assign var=col_name value=$field.col_name}
          {assign var=value value=$submission.$col_name}
          {if $col_name == "country"}
            {smart_display_field_values field_id=$field_id selected=$submission.country}
         {/if}
       {/foreach}
      </td>
    </tr>
    <tr>
      <td valign="top">Client number (additional text here)</td>
      <td class="big">{$submission.client_number}</td>
    </tr>
  </table>
  

{if !$smarty.foreach.row.last}
  <br />
  <div class="no_print"><i>- {$LANG.phrase_new_page} -</i></div>
  <br class="page_break" />
{/if}

{/foreach}

But I'm kind of surprised that this works...
Code:
{smart_display_field_values field_id=$field_id selected=$submission.country}

I've have thought that in the context, you'd need to use:
Code:
{smart_display_field_values field_id=$field_id selected=$value}

But whatever works!

For the second question - yes, pulling them out of sessions would have been my first guess, too. However I just looked over the code and the sessions aren't being passed to the template, so I'm afraid you can't. Sad

But this is very reasonable indeed. I'm going to jot it down as a feature request so I can include it in a new version. Stashing the client information in separate database fields would certainly work, but it would be such a shame - and a terrible hack...!

Sorry I couldn't be more help on that. Let me know how the first issue goes.

- Ben
Reply
#3
Tongue 
Hello Ben!
Thank you for reply Smile
About first question - the code between <td> tags you suggested works fine. Here it is:

Code:
{foreach from=$display_fields item=field name=col_row}
          {assign var=field_id value=$field.field_id}
          {assign var=field_type value=$field.field_info.field_type}
          {assign var=col_name value=$field.col_name}
          {assign var=value value=$submission.$col_name}
          {if $col_name == "country"}
          {smart_display_field_values field_id=$field_id selected=$value}{/if}
{/foreach}

but here is my version of code that also works between <td> tags (I was playing with my template before I got your reply. Wink):

Code:
{foreach from=$display_fields item=field name=col_row}
      {if $field.col_name == "country"}
      {smart_display_field_values field_id=$field.field_id  selected=$submission.country}
      {/if}
      {/foreach}

I'm VERY new to smarty templates, so please help me decide which one is better.

I also thought this code:

Code:
{foreach from=$display_fields item=field name=col_row}
          {assign var=field_id value=$field.field_id}
          {assign var=field_type value=$field.field_info.field_type}
          {assign var=col_name value=$field.col_name}
          {assign var=value value=$submission.$col_name}
{/foreach}

should be on the beginning of template (+ code between td tags), but obviously not, so I deleted it. Thanks!

About my second question:

The code:

Code:
{$smarty.session.ft.account.account_id}
{$smarty.session.ft.account.first_name}
{$smarty.session.ft.account.last_name}
{$smarty.session.ft.account.email}

WORKS in template. It displays id, first and last name and email of the client! I got idea from your reply to another thread. You posted code similar to this:

Code:
<?php
$account_info = ft_get_account_info($_SESSION["ft"]["account"]["account_id"]);
$emailaddress = ($account_info['email']);
$client_first_name =($account_info['first_name']);
$client_last_name =($account_info['last_name']);
$client_address = $account_info["settings"]["ecf_1"];
$client_place = $account_info["settings"]["ecf_2"];
$client_post_zip = $account_info["settings"]["ecf_3"];
?>

So, I tried to make it in smarty - I have special trial and error method Smile, but I also need some additional fields from Extended Client Fields. Any ideas how to do it?

Thank you VERY MUCH,
Lina
I got it! My special method, remember? Smile

This is code to display id, first and last name and email of the client:

Code:
{$smarty.session.ft.account.account_id}
{$smarty.session.ft.account.first_name}
{$smarty.session.ft.account.last_name}
{$smarty.session.ft.account.email}

and this is code to display fields from Extended Client Fields Module:

Code:
{$smarty.session.ft.account.settings.ecf_1}
{$smarty.session.ft.account.settings.ecf_2}
{$smarty.session.ft.account.settings.ecf_3}
{$smarty.session.ft.account.settings.ecf_4}
{$smarty.session.ft.account.settings.ecf_5}

It works great in my template, but please check all of my template code. I don't want to run into problems later.

Thank you sooooo much for Form Tools,
Lina
Reply
#4
Excellent! Sounds like you made loads of progress! Smile

Quote:I'm VERY new to smarty templates, so please help me decide which one is better.

Yours! All those declared variables weren't needed, so yours is more readable (and a teany bit faster) Smile

And haha, very well done sniffing out the use of the $smarty.session.ft space. I totally didn't spot that. Very well done indeed - I'm going to start asking you questions soon (you think I'm joking, but maybe not... Wink )

- Ben
Reply
#5
Ben,
thank you sooo much for your kind reply, but you are still master for me Smile

I have a new problem:

There is a small dropdown list in my form with field values / display text 0/A and 1/B.
When option A is selected, it doesn't work in any of prebuilt smarty templates - the field value is displayed instead of display text. It works fine for option B.
Both options are displayed correctly on edit submissions page.
I suppose there is a problem in function.smart_display_field_values.php but I don't know how to fix it. Maybe you could check it out?

Anyway, thank you for cool and fantastic script Smile

Lina
Reply
#6
I found it! PHP.net manual is a great thing!

In file function.smart_display_field_values.php:

Code:
if (empty($selected))
return;

should be replaced with:

Code:
if (empty($selected) && !is_numeric($selected))
return;

because value 0 is treated as empty.

I love FormTools. Viva La Canada! Smile

Lina
Reply
#7
haha excellent. Glad you got it sorted out! Smile

- Ben
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)