You are not logged in.
I am trying to re-create Linker with a few different options. First let me say I love it! Second, the sites I have using xinha use mod_rewrite extensively and to say the least, scan.php just doesn't cut it for making links to pages. So, I have been trying to change Linker to allow for scan.php to have not only the url, but also text (like a page title and url), but without much luck.
What I would like to do is something of the sort:
[
[
['/','General'],
[
['/','Home'],
['/contact.php','Contact Us'],
['/staff/','Staff'],
['/links/','Links']
]
['/article/','Articles']
[
['/article/','Article List'],
['/article/1/','Article Title 1'],
['/article/2/','Article Title 2'],
['/article/3/','Article Title 3'],
['/article/4/','Article Title 4'],
['/article/5/','Article Title 5']
]
]
]
I hope that made some sense. Basically, instead of a file directory, it is a webpage directory tree. It would be easy to write scan.php to create the needed data, but I am totally lost in the Linker javascript.
I guess what I am asking for is an alternative focus for Linker, where I can choose between a file directory listing or a webpage directory listing, having the file directory accepting file path only while webpage directory accepting both title and url.
I would be glad to help, but I am really lost in the code. Sorry.
Last edited by riftdesign (2005-03-22 20:36:10)
rift design studio
[url]http://www.riftdesign.com[/url]
Offline
I hope that made some sense. Basically, instead of a file directory, it is a webpage directory tree. It would be easy to write scan.php to create the needed data, but I am totally lost in the Linker javascript.
Actually, I have this exact functionality working here with an older version of the Linker plugin. The content management portion of the business platform (mobie) we've developed does exactly that.
I've also got the edit case working where if it's a link in the tree it highlights it. I haven't had a chance to make my changes backwards compatible with the default linker which is why I haven't checked it in yet.
It loops through all the files you send back. In my case I'm sending files back as a single string from a modified scan.php as in:
['/,General'],
[
['/,Home'],
['/contact.php,Contact Us'],
['/staff/,Staff'],
['/links/,Links']
]
So each string has the name to be displayed in the tree and the value to assign as a single string separated by a comma. It's a major kludge ...
The trick is then in makeNodes(). Each string from your array is an entry in the files[] argument.
Linker.Dialog.prototype.makeNodes = function(files, parent)
{
for(var i = 0; i < files.length; i++)
{
if(typeof files[i] == 'string')
{
// the text to display is separated from the link by a ,
// file_args[0] == string to display
// file_args[1] == string to set in the URL.
var file_args = files[i].split(',');
this.dTree.add(Linker.nxtid++,
parent,
file_args[0].replace(/^.*\//, ''),
'javascript:document.getElementsByName(\'' + this.dialog.id.href + '\')[0].value=unescape(\'' + escape(file_args[1]) + '\');document.getElementsByName(\'' + this.dialog.id.type + '\')[0].click();document.getElementsByName(\'' + this.dialog.id.href + '\')[0].focus();void(0);',
file_args[1]);
}
else
{
// this entry in files is an array, so we recurse.
var file_args = files[i][0].split(',');
var id = this.Dialog_nxtid++;
this.dTree.add(id, parent, file_args[0].replace(/^.*\//, ''), null, file_args[0]);
this.makeNodes(files[i][1], id);
}
}
}
Hopefully this will help you get over the hump.
Contact me at http://www.formvista.com/contact.html if you get stuck; I can email you what I have.
-- Yermo
-----------------------------------------------------------------------------------------
Content Management with Business Intelligence [url]http://www.formvista.com[/url]
Offline
Yermo,
I implemented the changes you suggest and have had some success...here's the code I have at this time:
Linker.Dialog.prototype.makeNodes = function(files, parent)
{
for(var i = 0; i < files.length; i++)
{
if(typeof files[i] == 'string')
{
// the text to display is separated from the link by a ,
// file_args[0] == string to display
// file_args[1] == string to set in the URL.
var file_args = files[i].split(',');
this.dTree.add(Linker.nxtid++, parent,
file_args[1].replace(/^.*\//, ''),
'javascript:document.getElementsByName(\'' + this.dialog.id.href + '\')[0].value=unescape(\'' + escape(file_args[0]) + '\');document.getElementsByName(\'' + this.dialog.id.type + '\')[0].click();document.getElementsByName(\'' + this.dialog.id.href + '\')[0].focus();void(0);',
file_args[0]);
}
else
{
// this entry in files is an array, so we recurse.
var file_args = files[i][0].split(',');
var id = this.Dialog_nxtid++;
this.dTree.add(id, parent, file_args[0].replace(/^.*\//, ''), null, file_args[0]);
this.makeNodes(files[i][1], id);
}
}
}
I have scan.php generating the following data scenarios:
SCENARIO 1:
['/,General']
SCENARIO 2:
['/,General'],[['/,Home'],['/contact.php,Contact Us'],['/staff/,Staff'],['/links/,Links']]
In Scenario 1, things work as planned...but Scenario 2 borks the code...
Error: files has no properties
Source File: http://domain.com/js/xinha/plugins/Linker/linker.js
Line: 398
Line 398 is
for(var i = 0; i < files.length; i++)
of the Linker.Dialog.prototype.makeNodes section.
Any thoughts?
rift design studio
[url]http://www.riftdesign.com[/url]
Offline
Hi,
As more and more php interfaces are created with Xhina, what do you think of formalize a little bit more the interaction between them? I personally don't use php but java with tomcat (no pb) but I think that if we can define an XML interface generic for all plugins it should be great...
No?
Offline
SCENARIO 1:
['/,General']
SCENARIO 2:
['/,General'],[['/,Home'],['/contact.php,Contact Us'],['/staff/,Staff'],['/links/,Links']]
Yea, the way this is set up you need to add a directory name so it should be
['General,/',[ 'Home, directory_name', ['Home,/', 'Contact Us,/contact.php', ...
I ran into the same problem ..
Last edited by Yermo (2005-03-23 03:55:44)
-----------------------------------------------------------------------------------------
Content Management with Business Intelligence [url]http://www.formvista.com[/url]
Offline
plase take a look at this thicket:
http://xinha.gogo.co.nz/cgi-bin/trac.cgi/ticket/67
i wrote allready a little patch, and gogo had a better idea
(a patch for the new version from gogo hasn't been written yet i think)
Niko
Offline
plase take a look at this thicket:
http://xinha.gogo.co.nz/cgi-bin/trac.cgi/ticket/67
i wrote allready a little patch, and gogo had a better idea
(a patch for the new version from gogo hasn't been written yet i think)
Yea, my approach was just a quick hack ...
-----------------------------------------------------------------------------------------
Content Management with Business Intelligence [url]http://www.formvista.com[/url]
Offline
i just wrote the patch...
http://xinha.gogo.co.nz/cgi-bin/trac.cgi/ticket/67
scan.php should return code like this:
[
"e.html",
['f.html', ['g.html','h.html']],
{url:'i.html',title:'I Html'},
{url:'j.html',title:'J Html', children:[{url:'k.html',title:"K Html"},'l.html',['m.html',['n.html']]]}
]
niko
Niko
Offline
plase take a look at this thicket:
http://xinha.gogo.co.nz/cgi-bin/trac.cgi/ticket/67
i wrote allready a little patch, and gogo had a better idea
(a patch for the new version from gogo hasn't been written yet i think)
I have applied the patch and have tried the methods described above without success. Are you currently using the same patch and the scan.php data that you mentioned?
rift design studio
[url]http://www.riftdesign.com[/url]
Offline
yes, exactly.
what is not working for you?
do you get JS-errors?
Niko
Offline
I don't have any JS errors, but Linker cannot parse the data and therefore doesn't do anything. This might be another issue to address for Linker (no parser feedback). I used your example for data from scan.php and I got nothing. When I click on the create hyperlink button, nothing happens. The same thing will happen if scan.php returns ill-formed data.
rift design studio
[url]http://www.riftdesign.com[/url]
Offline
what happens if you use
[
"e.html","f.html"
]
or
[
"e.html",
['f.html', ['g.html','h.html']]
]
does these work?
Niko
Offline
....and in FF what does you tell the JS-Console?
Niko
Offline
Well, nevermind...the JS must have been cached. It's working now. Thanks for helping Niko!
rift design studio
[url]http://www.riftdesign.com[/url]
Offline
ah, great
hopefully gogo will apply the patch soon
Niko
Offline
I still think there should be some kind of feedback if there is a malformed data source from scan.php. Maybe showing the dialog but with an error listed where the tree is would suffice.
rift design studio
[url]http://www.riftdesign.com[/url]
Offline
Could have a problem here...If the title has a single quote in the title (ie: Bob's Corner), it will not parse, and as mentioned earlier, there is no feedback as to the failure. I tried escaping the single quote with \' but that didn't seem to work either. Any thoughts here?
[
{url:'/',title:'Home', children:[{url:'/index.php',title:'Home'}, {url:'/calendar/',title:'Calendar'}, {url:'/contact.php',title:'Contact'}, {url:'/links/index.php',title:'Links'}]},
{url:'/ministry/children/',title:'Bob\'s Corner', children:[{url:'/ministry/children/',title:'Bob\'s Corner'}]}
]
Last edited by riftdesign (2005-03-25 18:53:20)
rift design studio
[url]http://www.riftdesign.com[/url]
Offline
You could do something like this in PHP --
htmlentities($title, ENT_QUOTES);
Learn how to astral project: [url]http://gnosticweb.org[/url]
Offline
You could do something like this in PHP --
htmlentities($title, ENT_QUOTES);
I don't know why that slipped my mind...thanks for the reminder. It worked great.
rift design studio
[url]http://www.riftdesign.com[/url]
Offline
Hi,
I give you too interesting links for this discussion
http://www.sitepoint.com/blog-post-view.php?id=191776
http://www.sitepoint.com/blog-post-view.php?id=165367
And also
http://developer.apple.com/internet/web … frame.html
Hope they will help to not reinvent the wheel...
Offline
Hi,
As more and more php interfaces are created with Xhina, what do you think of formalize a little bit more the interaction between them? I personally don't use php but java with tomcat (no pb) but I think that if we can define an XML interface generic for all plugins it should be great...
No?
I think thats great idea (i myself use modperl). It would would allow JS scripts not being altered and thus easier to update / share between different CMS systems.
U should start a ticket thingie bout it
[i]To live is to die ...[/i]
Offline
how do you return an "object" from PHP to Javascript?
Offline
you don't return a PHP-Object, you return a JavaScript-Code that represents an object (if executed)
which means you return a string like
{ 'index': 'value', 'foo': 'bar' }
so you return an object from php to js
Niko
Offline
ok, thanks. So, would the following code work in scan.php? I seem to have difficulty grasping this concept of passing 'objects' between languages...
<?php
....
$linkArray[] = "e.html";
$linkArray[] = "{url:'/',title:'Home', children:[{url:'/index.php',title:'Home'}]}";
echo to_js($linkArray);
?>
I bring this up because it keeps thinking it's a string, and I think I have applied the patch posted. If you have a direct link to the linker.js file that will interpret this correctly, please let me know. Thanks!
Last edited by g2010a (2005-03-31 14:28:27)
Offline
i wrote a additional patch for scan.php, take a look at it:
http://xinha.python-hosting.com/ticket/67
you can use the to_js function directly...
Niko
Offline