solved Smarty PHP Include

SoftDesigns
SoftDesigns
@softdesigns
7 years ago
242 posts
We are hosted on JR pro server, and it seems Smarty is already installed.
Our goal is a simple JR integration using PHP + Smarty, outside of JR framework, but still on our JR pro server.
--
If we create a root folder (outside of the JR framework) for example: http://OurSite/dev
How to include smarty in raw PHP - in this way - outside of JR framework, but still on our JR server?
--
Code Below Fails:
We assume the include is not valid.
How to include Smarty in raw PHP on our JR pro server?
--
include('Smarty.class.php');

// create object
$smarty = new Smarty;

// Simple Smarty Test:
$smarty->assign('name', 'george smith');
$smarty->assign('address', '45th & Broadway');

// display it
$smarty->display('index.tpl');

updated by @softdesigns: 06/14/17 07:56:49PM
paul
@paul
7 years ago
4,326 posts
I cannot answer your smarty question, but would advise that our servers are configured just for Jamroom sites and to run them just for that purpose, so we are not going to make any server level changes that you might need for your 'non-Jamroom' application. Also, if your application compromises the JR site at all, we cannot support it.
Hope that helps.


--
Paul Asher - JR Developer and System Import Specialist
michael
@michael
7 years ago
7,714 posts
why?

why not build it as a module.
SoftDesigns
SoftDesigns
@softdesigns
7 years ago
242 posts
@paul - @michael : We may be on the wrong track, and always prefer building custom JR module. Maybe we were confused Based on ticket# 49558 reply, it sounded like it was not possible to inject custom code inside a profile custom page.
--
Always prefer JR module if possible, but this code needs to be inside page like:
--
OurSite.com/MyProfile/page/1/DevPage
--
We see a basic html source code edit box area, on these types of pages, but we need a code widget or module.

Is it possible to have a code module inside a profile additional add-on pages?
updated by @softdesigns: 03/16/17 12:37:22AM
michael
@michael
7 years ago
7,714 posts
(I'm) not following that ticket very easily.

also not following the question, hit me with a desired outcome. :)

sounds like you're trying to add some extra stuff to a page created by the page module. that should be doable. what do you want to inject? that line of javascript? where is that coming from?? is it user input or is it going to be the same thing for every page? or is it set by the admin?? or could we just hard code it into the module that injects it??

There are a ton of events to listen for to get it there, knowing the surrounding situation will help identify which is the best event to use.
michael
@michael
7 years ago
7,714 posts
A basic last resort scenario:
* listen for the 'view_results' event

That event has the completed page as html before it is rendered. check the url is the one you're interested in and use str_rep to inject it just before the /HEAD or somewhere into the body.

There probably is a better event though.
SoftDesigns
SoftDesigns
@softdesigns
7 years ago
242 posts
@michael : Yes, we want to inject custom HTML and JavaScript code, in pages created by the page module. All the custom code will only be setup by admin, stored in CDN or local files on our JR server. The custom code will vary based on unique Page ID or Page URL. This technique, combined with mapped profile domains, allows building very powerful sub modules under a main JR site.
--
Maybe we can code solution using your above advice:
michael: listen for "view_results", check the url, and "str_rep to inject"
Will need time to study existing code for examples of those above listeners and functions...
--
michael: There probably is a better event though.
Can you think of any better event listener / functions to achieve this goal?
updated by @softdesigns: 03/16/17 12:52:50AM
michael
@michael
7 years ago
7,714 posts
that would be the LAST option I would choose. options I would try before that would be

$_js = array('source' => "{$_conf['jrCore_base_url']}/modules/jrCore/contrib/tinymce/tinymce.min.js?v={$_mods['jrCore']['module_version']}");
jrCore_create_page_element('javascript_href', $_js);
like this if I wanted to add in a linked .js file to the page, add that in a listener that fires at a point where all of the variables you are interested in are available.

find an event that happens exactly, or close to what you want, all the data for building that event will come in with ($_data, $_user, $_conf, $_args, $event)

so it will be easier to determine if you want to add your code in this instance or not.

If you use 'view_results'. all that data has been transformed into html, so its harder to use to test your variable against.

example:
http://yoursite.com/admin/page/1/testing-how-the-stuff-gets-here

see screenshot for all the events that fire and how many times they fire for that one url load.

a listener on any of them might give you more fine grained options if you find yourself needing more control.
events_fired.jpg
events_fired.jpg  •  134KB

SoftDesigns
SoftDesigns
@softdesigns
7 years ago
242 posts
@michael : Thanks for the info - jrCore_create_page_element - seems very promising...
--
Will need time to study this code above...
If further questions, will open a new more specific thread.
--
Great Support :) Solved
updated by @softdesigns: 03/16/17 06:07:23AM

Tags