Trying to place avatar on every page in PHPbb Forum. Only showing up in index page... any ideas? - phpbb

The website that im trying to make it work on is http://www.phone7forum.com/
The way I get it to show up on the index page is adding this code to the core index.php page right below this:
// Assign index specific vars
'S_AVATAR' => get_user_avatar(
$user->data['user_avatar'],
$user->data['user_avatar_type'],
$user->data['user_avatar_width'],
$user->data['user_avatar_height']
),
Then I can use {S_AVATAR} in my template but it ONLY shows up in the index file... So another phpbb guy suggested that I take that same code from above and place it in the includes/functions.php file right below this:
// The following assigns all _common_ variables that may be used at any point in a template.
I did that, and though it seemed to "try" and work I clicked on a few pages outside the index page and got a fatal error message:
Fatal error: Call to undefined function get_user_avatar() in /home/content/04/6534704/html/phone7forum/includes/functions.php on line 4385
Does anyone have any ideas?

IIRC get_user_avatar() is a function from functions_display. If you want to use it in the functions file, you have to include it.
Put it into an if condition to have it only load if you're on a page where function_display isn't already included:
if(!function_exists('get_user_avatar')){ include_once($phpbb_root_path . 'includes/functions_display.' . $phpEx); }

Related

showing error when accessing private property of ActivatedRoute in angular 5?

I am trying to store url paths into an array using 'activatedRoute.snapshot.url',it works nicely by storing the url paths into an array based on the '/' delimitor.But when I change my route into lazy loading it returns an empty array,after going through the properties of 'activatedRoute.snapshot' it returns the same results of 'activatedRoute.snapshot.url'(when using eager loading) in 'activatedRoute.snapshot._urlSegment.segments'
output
when I am using this property following error is shown in my terminal,but it also displays in my browser
ERROR in src/app/rcyc-components/rcyc-channels/rcyc-channels.component.ts(53,44): error TS2339: Property '_urlSegment' does not exist on type 'ActivatedRouteSnapshot'.
how can I solve this issue?Is there any other better way to get the current url paths into an array based on '/' seperator?
Try to use Location or Router services to extract URL from them.
https://angular.io/api/common/Location
https://angular.io/api/router/Router

Automatically add a voucher code if the URL conains a KeyWord in Prestashop

The main goal that I want to achieve is to add a voucher code if the user has clicked on a specific external link that point to my shop.
So the (javascript?) script will analyze the url and if it contains any selected keyword will add the voucher.
Anyone knows how to do that?
Thanks
I found a pretty simple solution.
I made a module.
You can find it here: GITHUB
Was pretty easy:
Generated a basic module HERE
Selected Header Hook for my new module
Modified the header hook function in the modulename.php file in root with this one:
public function hookHeader()
{
$this->context->controller->addJS($this->_path.'/views/js/front.js');
$this->context->controller->addCSS($this->_path.'/views/css/front.css');
if (Tools::getValue('voucher')){
$cartVoucher = Tools::getValue('voucher');
$idDiscount = Discount::getIdByName($cartVoucher);
Context::getContext()->cart->addDiscount($idDiscount);
}
}
Hope will help someone.
Thanks to all.

GetResource, dynamic parent.

my problem is the following. I'm currently making a blog-page with get-page, get-resources, form-it, and wayfinder. This question requires a decent amount of knowledge about Modx and snippits. I've got the page numberin and all working and i've got a template page with all my calls in it (called weblogTemplate). This template has the following wayfinder call in it :
[[!getResources? &parents=`5` &limit=`5` &tpl=`blogPost`]]
[[!getPage?
&elementClass=`modSnippet`
&element=`getResources`
&parents=`4`
&depth=`2`
&limit=`5`
&pageNavOuterTpl=`[[+first]][[+prev]][[+pages]][[+next]][[+last]]`
&pageVarKey=`page`
&pageFirstTpl=`<li class="controlFirst"><a[[+classes]][[+title]] href="[[+href]]">Eerste pagina</a></li>`
&pageLastTpl=`<li class="controlLast"><a[[+classes]][[+title]] href="[[+href]]">Laatste pagina</a></li>`
&pagePrevTpl=`<li class="controlPrev"><a[[+classes]][[+title]] href="[[+href]]"><<</a></li>`
&pageNextTpl=`<li class="controlNext"><a[[+classes]][[+title]] href="[[+href]]">>></a></li>`
&includeTVs=`1`
&includeContent=`1`
&tpl=`blogListPost`
]]
as you can see the parent is set here to id number 5. This is fine for the homepage but any child page connected in the blog page also uses the same template and so would also have the same menu as the parent. You could use a fix to simply create 1 template for a page and keep using a different getResource call but keep in mind that it is a blog im making, new pages keep getting added. The user can't (, and wouldn't even understand to) make a template and edit any code. A solution i thought of would be to make the parent id dynamic, so it adjust to whatever page it is currently on. So for example if it was on the page with id number 12 it would make the parent call set to 12 and so show all the content under id number 12. If anyone has any ideas / thoughts / solutions i would be very grateful to hear them.
(a link about wayfinder that i used.)
The best solution would be to use two templates - one for main and one for the blog pages and use in blog templates:
&parents=`[[*id]]`
The problem with the user solveds by setting default_template in the system settings.
This worked for me:
[[!getPage?
&elementClass=`modSnippet`
&element=`getResources`
&parents=`[[*id]]`
&depth=`0`
&limit=`10`
&pageNavOuterTpl=`[[+first]][[+prev]][[+pages]][[+next]][[+last]]`
&pageVarKey=`page`
&pageFirstTpl=`<li class="controlFirst"><a[[+classes]][[+title]] href="[[+href]]">Eerste pagina</a></li>`
&pageLastTpl=`<li class="controlLast"><a[[+classes]][[+title]] href="[[+href]]">Laatste pagina</a></li>`
&pagePrevTpl=`<li class="controlPrev"><a[[+classes]][[+title]] href="[[+href]]"><<</a></li>`
&pageNextTpl=`<li class="controlNext"><a[[+classes]][[+title]] href="[[+href]]">>></a></li>`
&includeTVs=`1`
&includeContent=`1`
&tpl=`blogListPost`
]]
Thanks to Vasis for the provided help.

Opencart display one module conents into another module

I'm having custom footer module in my template. Also i'm using testimonial module in the position content bottom. I'm trying to display testimonial inside custom footer.
To do this i simply copied testimonial.tpl and testimonial.php contents and pasted into customfooter.tpl and customfooter.php
After this i'm getting errors stating
undefined variable and class name already assigned error
Did you know how to do this?
See this answer for how to do use a module in a separate modification/controller
opencart - How to manually display a module inside a template file?
You simply need to change from the common/home to your module's controller and view files
please define variable.
how can you define i will show you.
catalog > controller > header.php
for static variable
$this->load->language('common/header');
$data['text_home'] = $this->language->get('text_home');
// Where language file in assign this variable with different language foler
$data['text_home'] = $this->url->link('information/contact');
and you can tpl file in use this varible.
<?php echo $text_home; ?>
make sure 100% erorr has not facing
for dynamic variable

Get Page URL using Sitefinity 4 Fluent API

Okay, this seems like a pretty simple thing to do. But I'm trying to use the Sitefinity 4 Fluent API to query for a page and populate the Text/NavigationUrl properties of a HyperLink. The text gets populated fine - but it has a hard time getting the Url from the page.
PageNode page = App.WorkWith().Page(PageId).Get();
PageLink.Text = page.Title;
PageLink.NavigateUrl = page.Urls.Where<PageUrlData>(pU => pU.RedirectToDefault == false).FirstOrDefault<PageUrlData>().Url;
The first and second line work fine (PageLink.Text shows the page title). On the third line, I get an "Object reference not set to an instance of an object." error... FYI PageId is a Guid reference to a page.
Any help would be greatly appreciated.
Found the issue. PageNode requires "Telerik.Sitefinity.Pages.Model" as a reference. I had that, but later found that you ALSO need to include "Telerik.Sitefinity.Modules.Pages".
This adds a new method to my belt which I've used below (getFullUrl):
PageNode page = App.WorkWith().Page(PageId).Get();
PageLink.Text = page.Title;
PageLink.NavigateUrl = page.GetFullUrl();
Thanks