1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Using XenForo Bridge in Laravel - Need Templating Help

Discussion in 'XenForo Development Discussions' started by MatthewH, Jul 27, 2016.

  1. MatthewH

    MatthewH Member

    Hey everyone, I've been trying to figure this out. I'm using this package in my Laravel 5 application for bridging XenForo to Laravel. All is fine. It's just...templating.

    It always messes up. I just...I can't figure it out. Here's the function that's called on...here's the function eventually is called on.

    It's calling on XenForo_ViewRenderer_HtmlPublic, so obviously I don't quite understand what's going on here...

    Here's what it looks like by default...

    Here's what it looks like when I add 'Content' as a the content parameter.[​IMG]

    Even when making a custom template, nothing seems to work quite right...

    thanks for your help everyone.
  2. gabarba

    gabarba Member

    Hey I noticed you were having issues with the bridge you should have just opened an issue on github or messaged me directly :) Can you post the piece of code where you are calling the renderTemplate method?
  3. MatthewH

    MatthewH Member

    Sorry, didn't realize you were on here! Well glad someone finally can help.

    I don't have the code on me right now, but how would you properly use this? Would I have to create custom templates in XenForo? God I hope not. I've tried multiple ways. Ideally I would just like to pass a whole view through the content section. I would like to try to handle everything on Laravel side...but yeah.
  4. gabarba

    gabarba Member

    What content did you pass in? A laravel blade template? or just a straight up string? Blade should render to string properly.

    Also what xenforo template are you trying to render. It looks like judging from the screenshots you are rendering the PAGE_CONTAINER template within the PAGE_CONTAINER template. I just happen to open up the file right now and see that that I have added an additional parameter to the method signature called $container which is not included in the doc block. If you used the default values of $name and $container I suspect that is what you are getting above. I use the bridge to render other xenforo templates into the PAGE_CONTAINER and do not rely on the default template name in the signature anymore which may be why I had not come across this bug.

    If you could test it out by calling a different xenforo template

    renderTemplate({DIFFERENT_TEMPLATE},{YOUR CONTENT}.{VIEW_PARAM} = array())
    Its been a while since I've touched this code but I believe I made the signature back words compatible with how I was using it for my application along wit the fact that there were 2 other people using it so I didn't want to change everything up and break other peoples code. I had started on a 2.0 revision but since I particularly did not have a need to update it right away I kept it the way it was. Generally when I use the method I call it like this

    As you can see I do not pass laravel blade or content directly any more because it made our project to complex having 2 different templates rendering engines being used ie Blade and Xenforo. Plus my partner on the project did not know Laravel or Blade but was well versed in Xenforo so it made more sense to keep all template work in Xenforo.

    The signature was left the way it was only because there is 2 places in my code base that still use Laravel Blade to render the content only because it was easier to implement with an existing library that I had created and did not at the time want to re-implement it for Xenforo templating.

    I quickly pushed a fix to a new branch you can download that branch and see if that fix will solve your issue. The new temp branch is called default_template_rendering_fix
  5. MatthewH

    MatthewH Member

    Okay, I'll take a look at the branch tomorrow night after work. I'm actually headed out for the night. Thank for your help!
  6. Nobita.Kun

    Nobita.Kun Well-Known Member

    You are calling twice render an template. renderView still call to renderContainer.

    So i think lines from 46 to 49:
    return $response->renderContainer(
    Should be to:
    return $response->renderView('urb_itemhub_view'$finalParams$name);
  7. gabarba

    gabarba Member

    That is similar to the fix I pushed on a separate branch


    The issue with your solution is it doesn't account for the fact that someone may want to use the PAGE_CONTAINER and inject content into it. I agree that the api is inconsistent and should have separate methods, but that will come with a 2.0 version. It just so happened that it was initially written similar to the way you just proposed.
  8. Nobita.Kun

    Nobita.Kun Well-Known Member

    Do you look around responseView method? It able bypass data to container :)
  9. gabarba

    gabarba Member

    Hmm I'll have to check that out when I get a chance I have a feeling there was another reason for what I ended up doing. It's been a year now since I've looked at this particular piece of code so I'll have to dig into it in detail later in the week.

Share This Page