Jump to content

alecthorne

Members
  • Posts

    15
  • Joined

  • Last visited

Profile Information

  • Gender
    Not Telling

alecthorne's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. Dear requinix and benanamen, apologies for the extremely late reply to both your answers. Sadly the syntax of the array is set by the ZOO application I use for Joolma. The PHP routines I wrote originally are extremely old, and sadly represent my lacking knowledge in PHP, but I would like to update the values in-line with what I have written before (if possible) I tried the following, but the new value is not returned to the array $zooelements["de37ea08-9c88-4479-8453-fc020fe91eb9"] = "NameEFGH"; $query5 = "UPDATE link_zoo_item SET elements=$zooelements WHERE id=$id"; $result5 = mysql_query($query5); Is there something that I have missed? Many thanks, Alec
  2. I am using the application ZOO with Joomla, which stores information within a multi dimensional array with a field named 'elements'. The format is similar to that shown below. { "0ad767a2-b0d6-42fe-abb9-cf7d3e62c88b": { "0": { "value": "NameABCD" } }, "4adc7e1d-1124-450a-986f-a4df1bb7b4c0": { "0": { "value": "E-MailABCD" } }, } I am not a php programmer, but with help I managed to extract the information using the a @mysql_query and the following: $elements = $row['elements']; $zooelements = json_decode($elements); $name = $zooelements->{"0ad767a2-b0d6-42fe-abb9-cf7d3e62c88b"}->{"0"}->value; My problem is if I want to change any value e.g. $name="NameEFGH", how can I propogate this new value back to the array using a @mysql_query such as: $query = "UPDATE link_zoo_item SET elements=???? Any help as a beginner would be much appreciated, Alec
  3. Have just seen the error and it works a treat. Thanks for pointing that out. Alec
  4. Just to start, I know very little about PHP. I am using Joomla 3.4.1 in combination with ZOO, and would like to extract the itemid (in this case 216) from a typical URL as that shown below: http://www.linkindustry.com/index.php?option=com_zoo&task=item&item_id=241&Itemid=216 I have tried using the suggestion below, found within another PHP question, however it sadly does not work: $db = JFactory::getDbo(); $articleid = JRequest::getInt('id'); echo $articleid; Can someone point me in the right direction. Many thanks, Alec
  5. Hello all. I am trying to change the 'Alias Slug' that a Joomla article uses to make each article unique. This needs to be achieved within a PHP routine, and thus far I have achieved the following: $slugreplace = "12345"; $query = "UPDATE yoo_zoo_item SET alias=$slugreplace WHERE id=$id"; This replaces the slug with "12345". However I would like to combine an integer with a string, as below $id = $row['id']; //this is the unique article item number $name = $row['name'];//this is the article title $slugreplace = $id.$name; $query = "UPDATE yoo_zoo_item SET alias=$slugreplace WHERE id=$id"; The original slug is not replaced. In fact, only when the variable $slugreplace contains an integer, is the slug replaced. Any value that contains a string is ignored. However I can replace the alias within Joomla itself to be any string/integer combination. What am I missing?? I have posted this on the Joomla forum, but no answer as yet. Maybe I am missing something with PHP here ? Thanks, Alec
  6. The Joomla ZOO extension places information within a multi-dimensional array named $elements. I display the array structure with: $arr = json_decode($elements,true);echo <pre>",print_r($arr,true),"</pre>"; The resulting array is below. Array ( [a3f9a1ba-85a2-4142-b0d6-6a85bef30cb5] => Array ( [0] => Array ( [value] => Telephone Number ) ) [e3145090-5017-44a9-bfaa-64602bacf96f] => Array ( [0] => Array ( [value] => Fax Number ) ) ) I need to be able to replace the value associated with a specific identifier ie. replace the ‘Telephone Number’ with another string $newdata, as this is associated with the identifier ‘a3f9a1ba-85a2-4142-b0d6-6a85bef30cb5’. I am new to this, but my initial attempt was as follows. $newdata = “ABCD”; foreach($elements as &$value) { $value['a3f9a1ba-85a2-4142-b0d6-6a85bef30cb5'] = $newdata; } This seems to have absolutely no effect. Can someone point me in the right direction. Thanks, Alec
  7. Thanks for the help. I started looking as treating this as an array, but then was also given the following suggestion. That also worked. $county = json_decode($elements); $printcounty = $county->{"c74a0dba-5307-4f90-b04e-fdc88c4dd434"}->{"0"}->value; Thank you all for the help, and encouragement to learn php further.. Much appreciated... Alec
  8. Christian, I have looked at multi-dimensional arrays, and thought the following would work. $county = $elements->getElement('c74a0dba-5307-4f90-b04e-fdc88c4dd434')->getElementData()->get('value'); All I receive is an internal server error. What have I missed? Thanks, Alec
  9. I used json_decode for the first time to extract data from the list below. { "metadata.title": "", "metadata.description": "CAD CAM Software Developer", "metadata.keywords": "CAD, CAM, Software", "metadata.robots": " ", "metadata.author": " ", "config.enable_comments": "0", "config.primary_category": "311" } This worked a treat using the following $catnum = json_decode($params); $catnum2 = $catnum->{'config.primary_category'}; But I am still stuck with the original question "c74a0dba-5307-4f90-b04e-fdc88c4dd434": { "0": { "value": "Norfolk" } As there are additional values after "c74a0dba-5307-4f90-b04e-fdc88c4dd434", how can I extract "Norfolk"? The following obviously did not work $county = json_decode($elements); $county2 = $county->{'c74a0dba-5307-4f90-b04e-fdc88c4dd434'}; echo $county2; I have looked at the help at php.net, but just cant get my head around this one. Thanks for your patience, Alec
  10. I have the following array within a field 'elements'. "b832581e-ef49-4cbf-a89b-7d67aa363e94": { "0": { "value": "Great Yarmouth" } }, "c74a0dba-5307-4f90-b04e-fdc88c4dd434": { "0": { "value": "Norfolk" } }, "91866e91-70d4-405f-900c-475d0c027399": { "country": { "0": "GB" } I was wanting tó extract the county 'Norfolk' and have tried the following $elements = $row['elements']; preg_match("@identifier=\"c74a0dba-5307-4f90-b04e-fdc88c4dd434\">\n*\s*<value><!\[CDATA\[([0-9]*)\]\]></value>@" , $elements, $array); $county=$array[1]; echo "<br>County=" . $county; This does not however extract the content from the identifier c74a0dba-5307-4f90-b04e-fdc88c4dd434 Have I missed something?? Thanks, Alec
  11. Christian, Thanks for the pointer. I worked in the following format $params_title="'{\"metadata.title\": \"{$name}\","; Thanks!! Alec
  12. Beginners question, I know. I have a variable $name (in this case 311) This needs to be inserted into another variable named param_title, so the result returns '{"metadata.title": "311", I have tried this with the following, but it does not return a result $params_title="'{"metadata.title":\"$name","; What am I doing wrong?? Thanks, Alec
  13. Thank you very much!! Worked a treat, and so simple when you know how. Thanks, Alec
  14. I am a total beginner at php, and have found a need for preg_match. Even after looking through posts here, this example is still rather beyond me. Can someone point me in the right direction. I have a string $params with the content as below. { "metadata.title": "", "metadata.description": "", "metadata.keywords": "", "metadata.robots": "", "metadata.author": "", "config.enable_comments": "0", "config.primary_category": "311" } How can I extract the value between the "" after the primary_category, in this case 311. Thanks, Alec
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.