Write XML from module_feusers_properties table?

Talk about writing modules and plugins for CMS Made Simple, or about specific core functionality. This board is for PHP programmers that are contributing to CMSMS not for site developers
Post Reply
JeremyBASS

Write XML from module_feusers_properties table?

Post by JeremyBASS »

hi so i'm takeing a stab at short cuts in the front end and i need to echo a xml to use... any tips here would be great as i have not gotten very far and a long while... thanks all


this a php being called by flash while logged in... here is the php... close? may-be?

Code: Select all

<?php

    $db=$this->GetDB();
    $q="SELECT * FROM ".cms_db_prefix()."module_feusers_properties WHERE title=? AND userid=?";
    $p=array($title,$userid);
    $result=$db->Execute($q,$p);
	echo "<?xml version=\"1.0\" encoding=\"iso-8859-1\" standalone=\"yes\" ?> 
	<links>";
    if ($result && $result->RecordCount()) {
      $row=$result->FetchRow();
	  
	echo "<link name=\"" . $row["data"] . "\" ref=\"http://www.sjrmc.org/St_Joe_Core/upload/\"/>";

    } else {
      	echo "<link name=\"Fail\" ref=\"http://www.sjrmc.org/St_Joe_Core/upload/\"/>";
    }
	echo "</links>";


/*	echo "<?xml version=\"1.0\" encoding=\"iso-8859-1\" standalone=\"yes\" ?> 
	<links>
	<link name=\"Upload\" ref=\"http://www.zzzzzzzzz.org/upload/\"/>
	<link name=\"Pictures & Videos\" ref=\"pictures.html\">
		<inLink name=\"Image Gallery\" ref=\"pictures.html\"/>
		<inLink name=\"Photoshop Tutorial\" ref=\"photoTut.html\"/>
	</link>
	<link name=\"Programming\" ref=\"xmlflash.html\">
		<inLink name=\"XML flash tutorial\" ref=\"xmlflash.html\"/>
		<inLink name=\"Nightshot Noise\" ref=\"nightShot.html\"/>
	</link>
</links>";*/
?>
Last edited by JeremyBASS on Tue Feb 26, 2008 6:40 pm, edited 1 time in total.
JeremyBASS

Re: Write XML from module_feusers_properties table?

Post by JeremyBASS »

so this is were i'm at

Code: Select all

    $db=$this->GetDB();
    $q="SELECT * FROM ".cms_db_prefix()."module_feusers_properties WHERE title=short_cut_list AND userid=".$userid."";
    $result=$q;
	echo "<?xml version=\"1.0\" encoding=\"iso-8859-1\" standalone=\"yes\" ?> 
	<links>";
    if ($result && $result->RecordCount()) {
      $row=$result->FetchRow();
	  
	echo "<link name=\"" . $row["data"] . "\" ref=\"http://www.sjrmc.org/St_Joe_Core/upload/\"/>";

    } else {
      	echo "<link name=\"Fail\" ref=\"http://www.sjrmc.org/St_Joe_Core/upload/\"/>";
    }
	echo "</links>";

If i use

Code: Select all

echo "<?xml version=\"1.0\" encoding=\"iso-8859-1\" standalone=\"yes\" ?> 
	<links>";
    if ($result && $result->RecordCount()) {
      $row=$result->FetchRow();
	  
	echo "<link name=\"" . $row["data"] . "\" ref=\"http://www.sjrmc.org/St_Joe_Core/upload/\"/>";

    } else {
      	echo "<link name=\"Fail\" ref=\"http://www.sjrmc.org/St_Joe_Core/upload/\"/>";
    }
	echo "</links>";
then "Fail" shows up so i know that it has to do with the way i'm calling the information... just not sure now... an ideas would be great and thank you all... :)
JeremyBASS

Re: Write XML from module_feusers_properties table?

Post by JeremyBASS »

ok so

Code: Select all

require_once(dirname(__FILE__)."/modules/FrontEndUsers/UserManipulator.class.php" );
require_once($dirname.'include.php');
    $q="SELECT * FROM ".cms_db_prefix()."module_feusers_properties WHERE title=short_cut_list AND userid=?";
    
	echo "<?xml version=\"1.0\" encoding=\"iso-8859-1\" standalone=\"yes\" ?> 
	<links>";
    if ($q) {
      $row=$q;
	  
	echo "<link name=\"" . $row['data'] . "\" ref=\"http://www.sjrmc.org/St_Joe_Core/upload/\"/>";

    } else {
      	echo "<link name=\"Fail\" ref=\"http://www.sjrmc.org/St_Joe_Core/upload/\"/>";
    }
	echo "</links>";
returned S as the 'data'... it should have been "something_1" "something_2" I want it to look like

Code: Select all

<?xml version="1.0" encoding="iso-8859-1" standalone="yes" ?> 
<links>
     <link name="something_1" ref="http://www.sjrmc.org/St_Joe_Core/upload/"/>
     <link name="something_2" ref="http://www.sjrmc.org/St_Joe_Core/upload/"/>
</links>
oh and the row looks like this
id    userid      title                      data 
12    3            short_cut_list        something_1,something_4,something_5

Any ideas ? laters
Last edited by JeremyBASS on Tue Feb 26, 2008 7:31 pm, edited 1 time in total.
JeremyBASS

Re: Write XML from module_feusers_properties table?

Post by JeremyBASS »

Well I'v been trying for a while now... i know that i'm on the right track, I'm just not a good coder... I am just wanting to get the Name=Value from a a FEU MultiSelect List property... 
I'm try to get the output like this:



     
     


I am just not sure on this and have been around and around for many hours... i know this will be handy as hell for others... i just need to get it to work lol... Any ideas would be great thank you... Laters :)

******update******

So I think i have the idea down now... I need to do a LEFT JOIN query to module_feusers_properties  with module_feusers_dropdowns where userid=?" (**which i don't understand yet on the ?**) I think thats right? than just call the option_name and option_text ... I'm just too new at the code area to know for sure... but i'll be giving it a try... if anyone can think of a better way or anything at all that would be great... thanks all...
Last edited by JeremyBASS on Wed Feb 27, 2008 8:55 pm, edited 1 time in total.
JeremyBASS

Re: Write XML from module_feusers_properties table?

Post by JeremyBASS »

Ok i'v made some head way i think but it leaves me with more questions now... I'll start with where i'm at...

Code: Select all

require_once(dirname(__FILE__)."/modules/FrontEndUsers/UserManipulator.class.php" );
require_once($dirname.'include.php');
    $q="SELECT * FROM ".cms_db_prefix()."module_feusers_dropdowns, ".cms_db_prefix()."module_feusers_properties".
	" WHERE userid=3 AND ".cms_db_prefix()."module_feusers_properties.title=".cms_db_prefix()."module_feusers_dropdowns.control_name AND ".cms_db_prefix()."module_feusers_properties.data=".cms_db_prefix()."module_feusers_dropdowns.option_name"; 
	 
	echo "<?xml version=\"1.0\" encoding=\"iso-8859-1\" standalone=\"yes\" ?> 
	<links>";
$result = mysql_query($q) or die(mysql_error());
while($row = mysql_fetch_array($result)){
 	echo "<link name=\"".$row['option_text']."\" ref=\"" . $row['option_name'] . "\"/>";
    }
	echo "</links>";
which works sort of, i put so pic to refer to but the prob is that although it did grab option_name & option_text it was only if it was not a MultiSelect List set... so from this i got:

Float_Pool - Float Pool

in stead of

Float_Pool - Float Pool
Path_5 - Value 5
Path_4 - Value 4
Path_3 - Value 3
Path_2 - Value 2
Path_1 - Value 1

So the questions...
1.)Ideas on how to take Path_1,Path_3,Path_5 and trun it in to what i want?
2.)What should the userid but set to? ... tryed $userid but that doesn't work or seem right(still not geting the '?' thing)
3.)how do i trim off Float_Pool - Float Pool?

Hope these are easy cause i'm pushed pass the edge and don't know where to go lol...  Thanks for any help
Attachments
ScreenHunter_01 Feb. 27 14.24.gif
ScreenHunter_01 Feb. 27 14.23.gif
calguy1000
Support Guru
Support Guru
Posts: 8169
Joined: Tue Oct 19, 2004 6:44 pm
Location: Fernie British Columbia, Canada

Re: Write XML from module_feusers_properties table?

Post by calguy1000 »

You're way off track.... you should have looked through the API in CMS Made Simple and written a simple UDT.

If you actually provide a description of what why I may be able to help.

it'd probably be easier to generate XML from CMS Made simple by simply generating another page template that has the xml template.... then a new page that uses that template, and some simple smarty code and maybe a UDT in the content of that page to pull the data.
Follow me on twitter
Please post system information from "Extensions >> System Information" (there is a bbcode option) on all posts asking for assistance.
--------------------
If you can't bother explaining your problem well, you shouldn't expect much in the way of assistance.
JeremyBASS

Re: Write XML from module_feusers_properties table?

Post by JeremyBASS »

Well it's being passed to flash and the flash is calling this php page to recive the XML it prased... I'm sorry i thought i said that, i get bass-ackwards sometimes when i'm learning lol...

Sorry i don't know what API or UTD is but i'll try looking it up... but i'm not sure i understand the whole use the template idea, but may-be after reading up on those.. thanks for the help...

*****Update******
Ok got that UDT and API now.... the input is in the FEU...
the idea is that a user has a MultiSelect List in their user settings or when signing up that they can pick from which when logged the  option_name & option_text that was select by the user will be passed to flash... I thought i was close cause i got option_name & option_text to passover to flash but just not via the useid and not the MultiSelect only the single... :)
Last edited by JeremyBASS on Wed Feb 27, 2008 11:01 pm, edited 1 time in total.
calguy1000
Support Guru
Support Guru
Posts: 8169
Joined: Tue Oct 19, 2004 6:44 pm
Location: Fernie British Columbia, Canada

Re: Write XML from module_feusers_properties table?

Post by calguy1000 »

Just for laughs and giggles I solved a similar problem using CMS,  and just a small user defined tag.

1) I created a new template called 'xml' that just had this:

Code: Select all

<?xml version="1.0" encoding="iso-8859-1" standalone="yes" ?> 
{content wysywig='false'}
2) I created a new page called 'xmltest' that I marked 'not shown in menu'
I added this code:

Code: Select all

<links>{get_user_properties uid=$smarty.get.uid assign='userprops'}
{foreach from=$userprops item='oneprop'}
    <link name="{$oneprop.data}"  ref="{$gCms->config.uploads_url}/" />
{/foreach}
</links>
3) I created a new user defined tag called get_user_properties that looks like this

Code: Select all

global $gCms;
$feu =& $gCms->modules['FrontEndUsers']['object'];
if( !$feu ) return;
if( !isset($params['uid']) ) return;

$props = $feu->GetUserProperties((int)$params['uid']);
$result = false;
if( $props[0] )
 {
    $result = $props;
 }
if( isset($params['assign']) )
  {
      $smarty =& $gCms->GetSmarty();
      $smarty->assign($params['assign'],$result);
      return;
  }

return $result;
4) I tested by accessing the url like this:
http://www.mysite.com/index.php?page=xmltest&uid=1
and doing a view source to see the resulting output

it worked just great.
Follow me on twitter
Please post system information from "Extensions >> System Information" (there is a bbcode option) on all posts asking for assistance.
--------------------
If you can't bother explaining your problem well, you shouldn't expect much in the way of assistance.
JeremyBASS

Re: Write XML from module_feusers_properties table?

Post by JeremyBASS »

Rock on i'm getting what you are doing there... but i think i must be super dumb here but how the heck would you get what i'm looking for... i mean as in the option_name & option_text though the userid... what you have won't do that right? when i tried it out the xml output worked but with all data...
-
 
 
 
 

looking for
-
 
 
 
 

This seems like a better way but i do know the smarty thing that well yet... i just don't think i have enough yet to work that... Lost lol thanks again for the help...
Last edited by JeremyBASS on Thu Feb 28, 2008 4:46 pm, edited 1 time in total.
calguy1000
Support Guru
Support Guru
Posts: 8169
Joined: Tue Oct 19, 2004 6:44 pm
Location: Fernie British Columbia, Canada

Re: Write XML from module_feusers_properties table?

Post by calguy1000 »

Well, I don't know exactly what you're trying to do.

I saw that you want to extract user properties and put them into xml, my example does that..

can you be more specific about: 
1) what user properties you have defined for users and their types
2) how you want them output in the xml file.

by looking at your stuff below, I'm guessing that you have a property in FEU called Path_1, what type is it? a dropdown field?  similarly with Path_3 and Path_5.... if they are dropdown fields, what are the possible values for them?
Follow me on twitter
Please post system information from "Extensions >> System Information" (there is a bbcode option) on all posts asking for assistance.
--------------------
If you can't bother explaining your problem well, you shouldn't expect much in the way of assistance.
JeremyBASS

Re: Write XML from module_feusers_properties table?

Post by JeremyBASS »

well... your guess was close to what i'm driving at... I have a property named "shortcuts", which is a drop down with MultiSelect... with
value1=path1
value2=path2
value3=path3
value4=path4
value5=path5
ect..
to be out putted like

 
 
 

based on what the user selects

*****update******
So i did some other test on this to make sure it's just the '___' in the XML that need to be worked on... but i did notice something that i think would be a problem... you said that i needed to access the page like such
http://www.mysite.com/index.php?page=xmltest&uid=1
and as it turns other that was the only way it would show up... do I need to put '?' in for 1 on the uid?  this needs to work on all users based on what they pick... but like i said i don't know the smarty thing that well ... but when i get some time later i'll start learning more on it... it's funny that this designer ever gets though the coding at all... lol... thanks again...


also i put up a pic... this is like admin short cuts for FEU.... with out needing a full module... :)
Attachments
ScreenHunter_01 Feb. 28 08.41.gif
Last edited by JeremyBASS on Thu Feb 28, 2008 4:46 pm, edited 1 time in total.
JeremyBASS

Re: Write XML from module_feusers_properties table?

Post by JeremyBASS »

Ok so after a few days of this i have gotten no where... it just keeps throwing errors... well on my tries to get the content of the sepcific drop down from FEU...  I've looked up and down in the files of the module... i didn't think getting this to work was going to be hard as it gets pulled in two different spots already... i just could not find any hints of what the smarty tags are...  Any ideas where to look?
JeremyBASS

Re: Write XML from module_feusers_properties table?

Post by JeremyBASS »

so I have not made any prgresstion in the sugessted way... so i took a nother run at the the only way i now how... and thought that i could convert it with the smarty tags?  well here is what i got to this point....

Code: Select all

require_once(dirname(__FILE__)."/modules/FrontEndUsers/UserManipulator.class.php" );
require_once($dirname.'include.php');
    $q="SELECT * FROM ".cms_db_prefix()."module_feusers_dropdowns, ".cms_db_prefix()."module_feusers_properties".
	" WHERE userid='3' AND ".cms_db_prefix()."module_feusers_properties.title='short_cut_list' AND ".cms_db_prefix()."module_feusers_properties.title=".cms_db_prefix()."module_feusers_dropdowns.control_name"; 
	 
	echo "<?xml version=\"1.0\" encoding=\"iso-8859-1\" standalone=\"yes\" ?> 
	<links>";
$result = mysql_query($q) or die(mysql_error());
while($row = mysql_fetch_array($result)){
 	echo "<link name=\"".$row['option_text']."\" ref=\"" . $row['option_name'] . "\"/>";
    }
	echo "</links>";
$query = "SELECT * FROM ".cms_db_prefix()."module_feusers_dropdowns, ".cms_db_prefix()."module_feusers_properties".
	" WHERE userid='3' AND ".cms_db_prefix()."module_feusers_properties.title='short_cut_list' AND ".cms_db_prefix()."module_feusers_properties.title=".cms_db_prefix()."module_feusers_dropdowns.control_name"; 
Still need to fix the userid='3' and split the values but they are coming now... any ideas would be great cause i'm spin my wheels and this need to work... lol... hopfuly sooner then later...
JeremyBASS

Re: Write XML from module_feusers_properties table?

Post by JeremyBASS »

I know I have not gotten very far on this... but I was wondering if someone could reexamine this, I could sure use the help on it... I want to use the smarty way... but I just was not getting the out put needed... So may-be if I give the user name and pass for the test account someone could see what I was needing... right now it's the php way... and it's outputting all the values just not the values that the user picks only...
user: testSTAFF
pass:321456
http://www.sjrmc.org/St_Joe_Core/
It's the "quick links at the top....



Thank you for taking that time... I know this will help to all when it's done... and I’ll post the fla file so it is complete... have a great one :)
JeremyBASS

Re: Write XML from module_feusers_properties table?

Post by JeremyBASS »

Although your solution does fall inline with the idea, it's far from the point for this thread, sorry.  This thread is about getting XML out put from feusers... bypassing feusers is not an option, and writing or saving the data back to the db is a must as well...  This still does need a solution.... but yes what you are talking about is something we talked about in posts about two months before this one ~I think~ ... you may want to check that out as your getting



and for more information that I was pulling it was getting like 6 - 7 queries... page=header-xml inserts many more queries then your needing... put it in debug and view the same page to see the extras... If you think of a way to do what i was aiming at please share, I know this is going to be a hot topic for the future and best to get a jump on it now :) laters...
Post Reply

Return to “Developers Discussion”