breadcrumb

12. Solid - static page About (II.)

Don't forget - it was written in 2014

comments: 0
Our today goal: e107plugin about page memberlist Note: If you use source code from part 11, don't forget change url configuration to get about page work (or link in sitelinks). I decided to use user's table for this, probably better would be featurebox or custom menu, but I wanted to try something new.

1. preparing data

- create userclass teammember e107plugin about page memberlist - set available option to upload photo e107plugin about page memberlist There is problem with photo upload, for temporarily fix change usersetting.php by this: https://github.com/e107inc/e107/pull/691 cca line 328: [sourcecode language="php"] $_POST['image'] = '-upload-'.$upload['name']; $_POST['user_sess'] = '-upload-'.$upload['name']; [/sourcecode] - create new users e107plugin about page memberlist Example: e107plugin about page memberlist So now we have data prepared: e107plugin about page memberlist

2. preparing layout

Easy. I have already theme plugin, so I will have the menu there: Layout: [sourcecode language="php"] $LAYOUT['solid_about'] = ' {---}
'; [/sourcecode] Tablestyle (we need new, because there id h3 tag, we have one with h2 tag) [sourcecode language="php"] if($style == 'teammember') { echo '

'.$caption.'

'.$text'; return; } [/sourcecode] We haven't menu yet, but layout works: e107plugin about page memberlist

3. create menu

- create file teammember_menu.php in themesolid plugin - add basic things to get it works Example: [sourcecode language="php"] <?php if (!defined('e107_INIT')) { exit; } e107::lan('core','user'); $text = " Our future team members"; $caption = "MEET OUR TEAM!"; $ns -> tablerender($caption, $text, "teammember"); ?> [/sourcecode] Result: e107plugin about page memberlist

4. working with database

- we need to get 4 records from database... - find ID of our teammember class e107plugin about page memberlist - connect with database - retrieve users from this class - check if foreach works correctly (only 4 records) [sourcecode language="php"] if (!defined('e107_INIT')) { exit; } e107::lan('core','user'); $caption = "MEET OUR TEAM!"; $userclass = 3; $sql = e107::getDb(); $teammembers = $sql->retrieve('user', '*', ' WHERE FIND_IN_SET('.$userclass.',user_class) ', TRUE); $text = ''; if($teammembers) { foreach ($teammembers as $teammember) { $text .= " Our future team members"; } } else { $text = "
No members
"; } $ns -> tablerender($caption, $text, "teammember"); [/sourcecode] Result: e107plugin about page memberlist

4. create menu / plugin template

- test with hardcoded member detail (before creating template): [sourcecode language="php"] foreach ($teammembers as $teammember) { $text .= '

Contact Me:

Mark Webber

CEO

Lorem Ipsum is simply dummy text of the printing and typesetting industry.

'; } [/sourcecode] Result: e107plugin about page memberlist - create template folder in themesolid plugin (We could use user_template.php in theme folder, but I wanted to test something new) - create themesolid_template.php file (look at user_template.php) [sourcecode language="php"] if (!defined('e107_INIT')) { exit; } global $user_shortcodes, $pref, $user; $THEMESOLID_TEMPLATE['teammember'] = '

Contact Me:

Mark Webber

CEO

Lorem Ipsum is simply dummy text of the printing and typesetting industry.

'; '; [/sourcecode] - use it in plugin menu: [sourcecode language="php"] // $template = e107::getTemplate('myplugin'); // loads e107_plugins/myplugin/templates/myplugin_template.php $TM_TEMPLATE = e107::getTemplate('themesolid'); [/sourcecode] e107plugin about page memberlist

5. use user shortcodes in menu

[sourcecode language="php"] $user_shortcodes = e107::getScBatch('user'); ... foreach ($teammembers as $teammember) { e107::getScBatch('user')->setVars($teammember); $TEAMMEMBER_TEXT = $tp->parseTemplate($TM_TEMPLATE['teammember'], TRUE, $user_shortcodes); $text .= $TEAMMEMBER_TEXT; } } [/sourcecode] e107plugin about page Result: (nothing should changed) e107plugin about page

6. use user shortcodes in template

- change hardcoded part with user shortcodes - carefull with image, set maximum size, theme is responsive, it changes size itself (thumb.php has default 20x20px} At first easy part: [sourcecode language="php"] $THEMESOLID_TEMPLATE['teammember'] = '

Contact Me:

CEO

Lorem Ipsum is simply dummy text of the printing and typesetting industry.

'; [/sourcecode]

Almost done.

We can't use use extended user fields, so try to something else. 1. member title - there is shortcode , when you check it, it use clean custom_title field, but you can't edit it in admin area. Insert data via phpmyadmin e107plugin about page memberlist [sourcecode language="php"]
[/sourcecode] Result: e107plugin about page memberlist2. member description Shortcode seems fine, we need set available this option: e107plugin about page memberlist [sourcecode language="php"]

[/sourcecode] - to solve correct order: [sourcecode language="php"] $teammembers = $sql->retrieve('user', '*', ' WHERE FIND_IN_SET('.$userclass.',user_class) ORDER by user_name', TRUE); [/sourcecode] Result: e107plugin about page memberlist Note: after changing usersetting, there is again problem with avatar, so next issue on github. 3. contact part e107plugin about page memberlist Send email: - send email should be easy, but there is spam problem, we can use , but this is deprecated. [sourcecode language="php"] [/sourcecode] - better idea is link to user profile where link is visible in safe mode [sourcecode language="php"] [/sourcecode] Note: I found emailto.sc with emailmember.php, probably something is prepared. Twitter: Extended fields doesn't work, so we can use only PM plugin. Activate it and then find better icon for it: [sourcecode language="php"] [/sourcecode]

So page About is finished:

e107plugin about page memberlist