Thread Rating:
  • 1 Vote(s) - 5 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Frontainer
#26
Hi jeckyl,

I am not sure if I have understood you properly, with "position", do you mean the field position or position of what?

Look, I have created a user "bigin" with following fields:

[Image: field-position.png?raw=1]

My PHP code in template:
PHP Code:
$userid 1;
$imanager imanager();
$user $imanager->getItem('slug=Users'$userid);

echo 
'<h2>User data</h2>';
echo 
'<table>';
foreach (
$user->fields as $data) {
    if(isset(
$data->value))
    {
        echo 
'
            <tr>
                <td><strong>'
.$data->label.': </strong></td>
                <td>'
.$data->value.'</td>
            </tr>
        '
;
    }
}
echo 
'</table>'

And here's my output, field position seems correct?:

[Image: user-data-output.png?raw=1]
Reply
#27
Ok, it's working for you but for me i have this result.

[Image: zokEcwz.jpg]

[Image: QbEZTU2.jpg]
Reply
#28
strange, have you tried my snippet, same result?

look at the "/data/imanager/fields/*.im.fields.xml" file, is there the order correct?

Show me your original code snippet for output pls
Reply
#29
(2017-02-07, 05:16:52)Bigin Wrote: strange, have you tried my snippet, same result?

look at the "/data/imanager/fields/*.im.fields.xml" file, is there the order correct?

Show me your original code snippet for output pls

same result with your code.

actually fields are displayed in ID's order and not Position's order.

Code:
<?php
// this lines should always be above the rest.
if(!defined('IN_GS')){ die('you cannot load this page directly.'); }

if(!isset($_SESSION)){session_start();}
$userid = (!empty($_SESSION['userid']) ? (int) $_SESSION['userid'] : false);
if (!$userid) {
   header('Location: http://xxxxxxxx.org/login/');
   exit;
}
$imanager = imanager();
$user = $imanager->getItem('slug=Users', $userid );
?>
Code:
<table class="invoices">
    <?php

    foreach ($user->fields as $data) {

       if (isset($data->value)) {

           echo '
               <tr>
                   <th>' . $data->label . '</th>
                   <td>' . $data->value . '</td>
               </tr>
           ';

       }

    }

    ?>
</table>
Reply
#30
Ok, there you have at least two options.
You can just reorder the fields each time you output the user data (simple solution but maybe a bit odd):

PHP Code:
$userid 1;
$imanager imanager();
$user $imanager->getItem('slug=Users'$userid);
$fieldMapper = new FieldMapper();
$fields $fieldMapper->filterFields('position''ASC', (array) $user->fields);
foreach(
$fields as $field) {
    ... 

My recommendation is, to reorder the fields according to their position and save them in this order. So you'll have to loop through users and re-save the fields id's, but only once. Then you must delete this snippet (Perform a backup of the "/data/imanager" folder before execute the code!):

PHP Code:
// Reorder item fields by position
$imanager imanager();
$category $imanager->getCategory('slug=Users');
$users $imanager->getItems($category->id);
$fieldMapper = new FieldMapper();
foreach(
$users as $user) {
    
$fields $fieldMapper->filterFields('position''ASC', (array) $user->fields);
    foreach(
$fields as $field) {
        
$field->id $field->position;
        
$field->save();
        
$user->fields->{$field->name}->id $field->position;
    }
    
$user->save();


Now you can use your snippet as before:

PHP Code:
// Dispalay user fields
$userid 1;
$imanager imanager();
$user $imanager->getItem('slug=Users'$userid);
echo 
'<table>';
foreach (
$user->fields as $data) {
    if(isset(
$data->value))
    {
        echo 
'
            <tr>
                <td><strong>'
.$data->label.': </strong></td>
                <td>'
.$data->value.'</td>
            </tr>
        '
;
    }
}
echo 
'</table>'
Reply
#31
Thanks
Reply
#32
Hello,
I'm testing the frontainer plugin but I can't get it running.
I use  GS 3.3.13 fresh install with the only installed imanager and frontainer plugins.
I have configured the required pages and items, but I can't enable the login feature.
Where am I wrong?
You can try url https://intento.ns0.it
Thank you
Reply
#33
Hi nicco,

I can't access the pages you have created, not a single one seems to be working well, look:

https://intento.ns0.it/login/
https://intento.ns0.it/recovery/
https://intento.ns0.it/signup/

I get 500 (Internal Server Error) there. You should disable all your plugins and fix the 500 error first, before you starting using frontainer.
Reply
#34
   
(2017-05-12, 20:38:15)Bigin Wrote: Hi nicco,

I can't access the pages you have created, not a single one seems to be working well, look:

https://intento.ns0.it/login/
https://intento.ns0.it/recovery/
https://intento.ns0.it/signup/

I get 500 (Internal Server Error) there. You should disable all your plugins and fix the 500 error first,  before you starting using frontainer.

Hi Bigin,
thanks for your quick interest!
I have attached what I get with url https://intento.ns0.it.
When I disable all plugins pages are completely white. I think because I modified the template.php as you indicated in the forum.
Thank you so much, if you want, I can PM you admin credentials.
Reply
#35
hmm, I believe that, what I have described in forum causes confusion, I'll change that description now..

First of, if you are working with PHP, in order to detect errors resulting from the code: turn on debug mode in gsconfig.php and enable full error reporting (including notices and messages), if necessary. then, however, you'll be able to recognize and eliminate such errors quickly and successfully.

Try the following, change the code in your template to this:

Code:
if(!defined('IN_GS')) die();
if(!isset($_SESSION)){session_start();}
$fnavi = array(
    'login' => null,
    'signup' => null,
    'accounts' => null,
    'logout' => null,
    'recovery' => null
);
$fcontent = '';
if(function_exists('frontainer_get_content')) {
    $fcontent = frontainer_get_content();
    $fnavi['login'] = htmlspecialchars(get_section_url(LOGIN_SLUG));
    $fnavi['signup'] = htmlspecialchars(get_section_url(SIGNUP_SLUG));
    $fnavi['accounts'] = htmlspecialchars(get_section_url(ACCOUNTS_SLUG));
    $fnavi['logout'] = htmlspecialchars(get_section_url(LOGOUT_SLUG));
    $fnavi['recovery'] = htmlspecialchars(get_section_url(RECOVERY_SLUG));
}

Then, change this line:
Code:
<?php echo $content; ?>

to this:
Code:
<?php echo $fcontent; ?>

And here's the code for your navi:

Code:
<ul class="nav navbar-nav">
    <li><a href="<?php get_site_url(); ?>forum/">Forum</a></li>
    <?php
    if(!isset($_SESSION['loggedin'])) {
        echo '<li ';
        if($id == $fnavi['login'] || $id == $fnavi['recovery'])
            echo 'class="active"';
        echo ' ><a href="'.$fnavi['login'].'">Login</a></li>';
        echo '<li ';
        if($id == $fnavi['signup'])
            echo 'class="active"';
        echo ' ><a href="'.$fnavi['signup'].'">Sign up</a></li>';
    } else {
        echo '<li ';
        if($id == $fnavi['accounts'])
            echo 'class="active"';
        echo ' ><a href="'.$fnavi['accounts'].'">Private</a></li>';
        echo '<li ';
        if($id == $fnavi['logout'])
            echo 'class="active"';
        echo ' ><a href="'.$fnavi['logout'].'">Logout</a></li>';
    }
    ?>
</ul>

These changes will fix the warnings "Undefined function or variable" when the frontainer is disabled. But! this will not fix your "500 Internal Server Error" and you'll still have to fix this issue.

As a last resort, you can send a PM with credentials ;-) good luck
Reply
#36
Hi Bigin,
You're right.
Now, with the disabled frontainer plugin, I reach home and see menu items.
But if plugin is activated:

Fatal error: Uncaught Error: [] operator not supported for strings in /srv/vhosts/intento.ns0.it/admin/inc/theme_functions.php:475 Stack trace: #0 /srv/vhosts/intento.ns0.it/plugins/frontainer.php(389): menu_data('login') #1 /srv/vhosts/intento.ns0.it/theme/Cardinal/template.php(14): get_section_url('login') #2 /srv/vhosts/intento.ns0.it/index.php(134): include('/srv/vhosts/int...') #3 {main} thrown in /srv/vhosts/intento.ns0.it/admin/inc/theme_functions.php on line 475

If you want look in pm.
Thank you so much.
Reply
#37
Hi nicco,

yes, because GetSimple attempting to use the short array push syntax on a string there O_o Probably you use PHP 7.1 and GetSimple does not support PHP 7.1 in this release, so you'll need to change to PHP7.0 or to fix many stuff yourself.
Reply
#38
(2017-05-13, 02:51:45)Bigin Wrote: Hi nicco,

yes, because GetSimple attempting to use the short array push syntax on a string there O_o Probably you use PHP 7.1 and  GetSimple does not support PHP 7.1 in this release, so you'll need to change to PHP7.0 or to fix many stuff yourself.

Hi Begin,
yes, I'm using 7.1.4.
Sorry if I've made you waste time, I'll have to look for another solution.
Thanks again.
Reply
#39
You're welcome! It doesn't matter what kind of plugin you will use, GetSimple does not properly run on PHP 7.1 >. But I wish you success in your work.
Reply
#40
To be fixed in 3.3.14
https://github.com/GetSimpleCMS/GetSimpl...ssues/1223
Reply
#41
there are more stuff to fix:

[Image: Screenshot%202017-05-12%2019.23.12.png]

[Image: Screenshot%202017-05-12%2019.22.57.png]
Reply




Users browsing this thread: 1 Guest(s)