i have this parsed object
$xmlObj = new SimpleXMLElement($XMLToParse, LIBXML_DOTTED_VERSION, FALSE, "http://SOME/schema/universal_v17_0");
that has the stucture like this inside it
<universal:UniversalR LocatorCode="somecode" Version="2" Status="Active">
<common_v17_0:Book Key="some" TravelerType="some">
so i can access the first element(its attributes) like this $VariableX=$xmlObj->UniversalR->attributes();//then $VariableX["Status"];
but when i want access his child i cant $tm=$xmlObj->UniversalR->Book->attributes();
it doesnt want to enter probably because of the different namespace...can any one help me . THX
I found something here http://blog.sherifmansour.com/?p=302
foreach ($xmlObj->UniversalRecord as $entry){
$namespaces = $entry->getNameSpaces(true);
$cmm = $entry->->children($namespaces['common_v17_0']);
$aa=$cmm->Book->attributes();
echo $aa["TravelerType"]."ddddd";
}
That should do it :)
$tm=$xmlObj->UniversalRecord->Book->attributes(); is this typo (UniversalRecord instead of UniversalR) only present in this post or is it also present in your code?
(I'd have liked to post this as a comment.. but it looks like i'm not allowed to, or am too stupid to find the button. :/)
Related
I've got a view (phase4) with some custom content type content in it, where the users may comment on.
When the users want to comment, the comment form should appear in a modal form. I solved this by using the admin overlay.
Adding following function to my custom module:
function phase2_admin_paths_alter(&$paths) {
$paths['comment/reply/*'] = TRUE;
}
and using following link:
Comment
to open the comment form in a modal way. So far so good... but....
How do I redirect the user back to the page, the user was coming from.
I know that I have to overwrite the #action of the form in the template_form_FORMID_alter, like
$form['#action'] = $lasturl;
but how do I get the last url, so that it is reusable (so hardcoding the url isn't an option)?
My first idea was that I transfer the last url by adding it to the url as a $_GET-parameter, but it looks like this:
www.example.com/phase4#overlay=comment/reply/161%3Furl%3Dphase4
I also tried it with drupal_get_destination(), but either with no success, because of the tranformation of the "?" and the "=" in the url.
Are there other ways to find out where the user was coming from?
Note: phase4 isn't the alias of node 161. Phase 4 is a view, where node 161 is an element of.
Cheers
Tom
You have to use the drupal_get_destination() function with l() function to create such links.
$destination = drupal_get_destination(); // Store current path
Comment
Inside embedded i18n form i need to get object.
In this example i got ArtistImageTranslation object, but i need ArtistImage.
Can somebody help me, how to get this?
class ArtistImageTranslationForm extends BaseArtistImageTranslationForm
{
public function configure()
{
$this->getObject();
....
}
}
Have you tried the following?
$artistimage = $this->getObject()->getArtistImage();
I spent half of day today on the same problem and looks like I finally found something ;)
First, if you need to access the fields which are in the "Translation" part of the table you can access them directly from the Object contained in the form. Just access the properties without using the getter (I know it's not the nice way but it works). So you can use something like:
$this->getObject()->id;
$this->getObject()->translated_name;
etc.
If you really need the original object you can access it like this:
$this->getObject()->getTable()->getRelation('ArtistImage')
->fetchRelatedFor($this->getObject());
Hope this helps.
Try :
$artistimage = $this->getObject()->artistImage;
or
$artistimage = $this->getObject()->artist_image;
If i do a mysql-select within the ts-setup and call the result of this select in, lets say, three extensions placed on the same site, does that still mean, that this certain mysql-select is done exactly once within each call of the site?
If so, it would be smarter to do the mysql-select in the typoscript and give the result to the extensions, so i dont have to do the same mysql-select over and over for each extension again, right?
Or is the text from the typoscript handled another way?
Thanx in advance,
Jayden
If that are exactly the same request, it will hopefully cached by mysql-query-cache. But, you are right, the request will be send three times.
If i understand you right, you think about doing sth. like:
lib.mySqlSelect = CONTENT
lib.mySqlSelect ...
plugin.tx_yourplugin.select.cObject < lib.mySqlSelect
That would result in three SQL Querys too.
But you could use an LOAD_REGISTER:
plugin.tx_yourplugin.select = {register:mySqlSelect}
plugin.tx_yourplugin.select.insertData = 1
page.1 = LOAD_REGISTER
page.1.mySqlSelect = CONTENT
page.1.mySqlSelect ...
Assuming "select" has stdWrap property.
If you are writing a new extension, you could use $GLOBALS['TSFE']->register[$register] = $theValue;
I use modules layout to structure my controllers:
:module/:controller/:action
I would like to add a new custom route so that the following url will work.
domain.com/username
where username is a username of any registered user on the website.
Can anyone point me in the right direction?
Thank you
See this blog post for a detailed explanation of how to do this in ZF:
http://tfountain.co.uk/blog/2010/9/9/vanity-urls-zend-framework
Not sure if you can make something like domain.com/username. Instead you could do domain.com/u/username or domain.com/user/username. For example, to make the second route in you application.ini you could put something similar to the following:
resources.router.routes.user.route = "/user/:user"
resources.router.routes.user.type = "Zend_Controller_Router_Route"
resources.router.routes.user.defaults.module = default
resources.router.routes.user.defaults.controller = user
resources.router.routes.user.defaults.action = user
resources.router.routes.user.defaults.user =
resources.router.routes.user.reqs.user = "\s+"
http://framework.zend.com/manual/en/zend.controller.router.html covers quite well all the different ways you can add routes. Keep in mind, once you add custom routes, the default one will not work anymore unless you explicitly define it (as well as in url view helpers etc.).
I tried to write in the CustomRules.js in OnBeforeResponse method:
if(oSession.PathAndQuery.StartsWith("/feed/predata/1-1-"))
{
oSession["PathAndQuery"] = oSession.PathAndQuery.Replace("false","1");
}
The full PathAndQuery looks like that
/feed/predata/1-1-false-2.dat
When i try to save the file I get an error sound without a messagebox to show me where the error is.
I also tried this code:
oSession.PathAndQuery = oSession.PathAndQuery.Replace("false","1");
What is the correct way to perform this action?
Thanks in advance,
Oz.
If you're trying to change the request, you need to put your code in the OnBeforeRequest method.
Also,
oSession["PathAndQuery"]
doesn't do anything you want it to. Use this instead:
oSession.PathAndQuery = oSession.PathAndQuery.Replace("false","1");