I define 2 variables, baseURL and imageName.
And the actually image url is the combination of baseURL and ImageName.
For example, baseURL is "http://www.abc.test" and imageName is "Hello.jpg".
How to display the "http://www.abc.test/Hello.jpg" by baseURL and imageName variables?
Just write
$baseURL/$imageName
in your template, for instance:
<img src="$baseURL/$imageName"/>
If you want to concatenate those two variables in another variable, do:
#set($url = "$baseURL/$imageName")
Related
I have created a component and need to get a constant value in the component administrator and list the item according to it. I have tried different ways to get the constant value in the 'display()' function in 'view.html.php'. I am expecting the value will be available in the default.php with $this.
I have defined the constant in the configuration.php file, A URL is supposed to define.
define('CONSTANTVALUE', 'the URL string');
in the display() function,
$config = JFactory::getConfig();
$constantvalue = $config->get('CONSTANTVALUE');
$this->constantvalue= $constantvalue;
Seems this is not working.
Then, I have tried
JFactory::getApplication()->get('CONSTANTVALUE');
That also not working.
I have referred to this thread, Joomla 3 - How to get value from configuration file?
How can I get the constant from configuration to component view file?
XPages Dojo Data Grid and Custom REST Service
*** Note: Mine is an XPINC application!
I've managed to get the above method working, but I want to pass a parameter through to the Rest Service in order to build a better return set.
In the above example it the script looks like this:
<script>
var jsonStore = new dojo.store.JsonRest(
{target:"CURRENT_PAGE_NAME_HERE.xsp/gridData"}
);
var dataStore = dojo.data.ObjectStore({objectStore: jsonStore});
</script>
But, I want to do something like this:
<script>
var jsonStore = new dojo.store.JsonRest(
{target:"CURRENT_PAGE_NAME_HERE.xsp/gridData?OpenXpage¶1=Value1¶2=Value2"}
);
var dataStore = dojo.data.ObjectStore({objectStore: jsonStore});
</script>
I've tried a number of methods, but no success.
Method 1 - Use Request/View/SessionScope variable
On the "CURRENT_PAGE_NAME_HERE.xsp" I've added a "xp:this.beforePageLoad" event to create Scope variable to hold para1 and para2 taken from the paramValues of the URL.
I thought a simple requestScope would store them so I could pick them up when the "CURRENT_PAGE_NAME_HERE.xsp/gridData" was called. However, the Rest Service is called in the "onClientLoad" event of the page and the Scope variables don't seem to be available at this time.
Method 2 - Inline Javascript
I've also tried "${javascript:viewScope.para1;}" to pass it through:
<script>
var jsonStore = new dojo.store.JsonRest(
{target:"CURRENT_PAGE_NAME_HERE.xsp/gridData?OpenXpage¶1=${javascript:viewScope.para1;}¶2=${javascript:viewScope.para2;}"}
);
var dataStore = dojo.data.ObjectStore({objectStore: jsonStore});
</script>
This didn't work.
Method 3 - Hardcoding
I have hardcoded the values.
<script>
var jsonStore = new dojo.store.JsonRest(
{target:"CURRENT_PAGE_NAME_HERE.xsp/gridData?OpenXpage¶1=Apples¶2=Oringes"}
);
var dataStore = dojo.data.ObjectStore({objectStore: jsonStore});
</script>
This works! But, only for Apples & Oranges
I'm starting to look at using an Environment Variable to pass the values, but this just seems to be more of a hack than a solution.
Any help or guidance would be appriciated.
Dan,
You may have a couple of things to check.
First thing is that you need to use # instead of $ to avoid
evaluating the expression on page load
In some cases you cannot inject SSJS into the CSJS - if this is "evaluated" at page load time. You could be hitting this.... An easy
way to check is to create a couple of local variables and assign the
values from your SSJS. That'll make it easy to debug in the browser.
I guess you could do something like this (and then you can set a breakpoint in your browser and see if the values are as expected).
<script>
var p1 = "#{javascript:viewScope.para1;}";
var p2 = "#{javascript:viewScope.para2;}";
var jsonStore = new dojo.store.JsonRest(
{target:"CURRENT_PAGE_NAME_HERE.xsp/gridData?OpenXpage¶1=" + p1 + "¶2=" + p2}
);
var dataStore = dojo.data.ObjectStore({objectStore: jsonStore});
</script>
If this does not work then I suggest creating a script block in the beginning of your page with a simple little "getter" method for each variable (or the entire arg. string) and then use the SSJS there.
Happy coding!
/John
As this is an XPINC appplication, I felt it was safe to just use an Environment Variable.
On the view action button that calls the XPage, I write the Environment variable down onto the system. Then when I open the Xpage in the client, the Rest Service is hardwired to:
var param1:String = session.getEnvironmentString("Param!");
I still think this feels more like a hack, but with Notes, I'm getting used to it. LOL
I have a source connection reading and constructing my output all in javascript in the channel source.
I need to pass this along to access it from the destination.
So I use
globalChannelMap.put('fullMessage', fullMessage);
Inside the destination in the template window for File Writer I have
${fullMessage}
But it writes exactly that to the file. I want everything inside that variable to be written to the file.
Try this. Use intermediate variables, like:
var data = ${fullMessage};
var fullMessage = DateUtil.convertDate('dd/MM/yyyy', 'yyyyMMdd', $('data'));
globalChannelMap.put('${fullMessage}',fullMessage);
i am using in my unity project this method that saves the camera viewport to the file system:
Application.Capturescreenshot(fileName)
it is work great but i want it to be saved under a specific path.
for example : Application.Capturescreenshot(c:/screenshots/filename);
how can i managed this?
thnaks!
You could use the absolute file path easily by passing it as a string. In your case, using this statement should work just fine:
Application.CaptureScreenshot("C:/screenshots/filename");
Note that it will give you an error if screeshots folder does not exist. Hence, if you are uncertain of that, you could modify the code accordingly:
// File path
string folderPath = "C:/screenshots/";
string fileName = "filename";
// Create the folder beforehand if not exists
if(!System.IO.Directory.Exists(folderPath))
System.IO.Directory.CreateDirectory(folderPath);
// Capture and store the screenshot
Application.CaptureScreenshot(folderPath + fileName);
Lastly, if you want to use a relative path instead of an absolute one, Unity provides dataPath and persistentDataPath variables to access the data folder path of the project. So, if you want to store the screenshots inside the data folder, you could change the folderPath above accordingly:
string folderPath = Application.dataPath + "/screenshots/";
var nameScreenshot = "Screenshot_" + DateTime.Now.ToString("dd-mm-yyyy-hh-mm-ss") + ".png";
ScreenCapture.CaptureScreenshot(nameScreenshot);
Try this !
First of all I am using Play framework with scala.
I am creating a graph and with the node id I would like to show some information at the same page.
In order to do that, first I need to get node.name but for some reasons #node.name function is not working. When searching for it I learnt that it's because play is server-side and js is client-side. However I need to get the data somehow.
I also cannot access:
var html = "<h4>" + node.name + "</h4><b> connections:</b><ul><li>"
How can I access this through the view?
My second question is after reaching the js node.name, I need to access to controller and do the same action one more time but this time with the new node.name .
View Part:
onClick: function(node) {
#node.name
}
1) Is this code in your controller? And are the node variable in scope? If so this should be perfectly legal code, since it will be evaluated as pure scala.
2) The templates are a different story however. You probably know they parse everything as normal html, unless escaped. To use a variable you have to bring it into scope by either:
defining a 'constructor' for the template at the absolute beginning of the file:
#(node : Node)
...
#node.name // later in the file
See http://www.playframework.com/documentation/2.0/ScalaTemplates
or define a variable inside the template:
#defining( Get.node.from.somewhere ) { node =>
#node.name
}
See Play! framework: define a variable in template?
If you did either of the two, you should have no problem accessing the node variable. Even in scripts. But note that external scripts does not have access to the same variables. It is thus very common to use inline scripts or import it as another template if you need to access a variable from JavaScript.
Edit: I've made a gist of a template, controller and routes file: https://gist.github.com/Jegp/5732033