Jump to content

joe_ma

Members
  • Posts

    182
  • Joined

  • Last visited

Everything posted by joe_ma

  1. Hmm, I think I tried this before … but don't know for sure. Anyway: $vorstand = $page->children(); echo $vorstand->count(); Doesn't change anything. Echoes "0". Ehm … the subpages are all hidden. Could this be the reason? Edit: YES! That IS the reason. Is there a way to list hidden pages? Edit 2: Yes, there is: use "include=hidden" as a selector.
  2. Output: 0 (zero) But several of these pages have the checkbox checked.
  3. Hello I try to generate a table of persons in template. All the persons are children of a page with this template. The childrens template contains these fields: - title (name of the person) - funktion (textfield) - email - vorstand (checkbox) - org_kom (checkbox) My code to generate the table looks like this: $vorstand = $page->children("vorstand=1, sort=sort"); $content .= "<table border='' class='whoiswho'>"; foreach ($vorstand as $v){ $content .= "<tr><td>{$v->title}</td><td>{$v->funktion}</td><td>{$v->email}</td></tr>"; } $content .= "</table>"; All I get in the output is: <table border='' class='whoiswho'></table> I am not able to see where I went wrong.
  4. OK, so I changed line 4 of the code here above to if ($page->fields->adr_rubrik) { And now everything works fine. Thank you all for your patience and help.
  5. Doesn't really surprise me … The adr_rubrik field allows more than one category to be selected. Therefore I thought, I had to iterate through these as well. I tried to adopt your code. It now looks like this: $out = ''; $rubrik = false; if ($page->template->has('adr_rubrik')) { $rubrik = $page->adr_rubrik; } if ($rubrik && count($rubrik)) { $list = $pages->find("template=adress_daten, adr_rubrik=$rubrik, include=all"); if (count($list)) { $out .= '<table id="myTable" class="tablesorter adressliste display"> <thead> <tr> <th class="inst">Institution</th> <th class="plz">PLZ</th> <th class="ort">Ort</th> <th class="inst_info">Beschreibung</th> </tr> </thead> <tbody>'; foreach($list as $l) { $out .= "<tr><td>"; if($l->adr_firma) $out .= "$l->adr_firma <br>"; if($l->adr_abteilung) $out .= "$l->adr_abteilung <br>"; if($l->adr_vorname) $out .= "$l->adr_vorname <br>"; if($l->adr_name) $out .= "$l->adr_name <br>"; if($l->adr_strasse) $out .= "$l->adr_strasse <br>"; if($l->adr_postfach) $out .= "$l->adr_postfach <br>"; if($l->adr_tel) $out .= "$l->adr_tel <br>"; if($l->adr_fax) $out .= "$l->adr_fax <br>"; if($l->adr_email) $out .= "$l->adr_email <br>"; if($l->adr_web) $out .= "<a target='_blank' href='$l->adr_web'>website</a> <br>"; if($l->adr_webzusatz) $out .= "<a target='_blank' href='$l->adr_webzusatz'>zusätzliche Website</a>"; $out .= "</td><td>"; $out .= $l->adr_plz; $out .= "</td>"; $out .= "<td>"; $out .= $l->adr_ort; $out .= "</td>"; $out .= "<td>"; $out .= $l->adr_beschreibung; $out .= "</td></tr>"; } } $out .= '</tbody></table>'; $content .= $out; } This leads to nothing being output in both cases.
  6. var_dump($rubrik) where field is not empty: object(PageArray)#352 (7) { ["hooks"]=> array(2) { ["PageArray::render"]=> string(60) "MarkupPageArray->renderPageArray() in MarkupPageArray.module" ["PageArray::renderPager"]=> string(56) "MarkupPageArray->renderPager() in MarkupPageArray.module" } ["count"]=> int(1) ["items"]=> array(1) { [0]=> string(31) "/de/adressen/rubriken/religion/" } ["total"]=> int(1) ["start"]=> int(0) ["limit"]=> int(0) ["selectors"]=> string(0) "" } var_dump($rubrik) where field is empty: object(PageArray)#352 (7) { ["hooks"]=> array(2) { ["PageArray::render"]=> string(60) "MarkupPageArray->renderPageArray() in MarkupPageArray.module" ["PageArray::renderPager"]=> string(56) "MarkupPageArray->renderPager() in MarkupPageArray.module" } ["count"]=> int(1) ["items"]=> array(1) { [0]=> string(30) "/de/adressen/rubriken/vereine/" } ["total"]=> int(1) ["start"]=> int(0) ["limit"]=> int(0) ["selectors"]=> string(0) "" } var_dump($list) where field is not empty: object(PageArray)#363 (7) { ["hooks"]=> array(2) { ["PageArray::render"]=> string(60) "MarkupPageArray->renderPageArray() in MarkupPageArray.module" ["PageArray::renderPager"]=> string(56) "MarkupPageArray->renderPager() in MarkupPageArray.module" } ["count"]=> int(3) ["items"]=> array(3) { [0]=> string(44) "/de/adressen/adressdaten/familientreff-bern/" [1]=> string(50) "/de/adressen/adressdaten/muetterzentrum-bern-west/" [2]=> string(45) "/de/adressen/adressdaten/stiftung-idee-sport/" } ["total"]=> int(3) ["start"]=> int(0) ["limit"]=> int(0) ["selectors"]=> string(38) "template=adress_daten, adr_rubrik=1273" } object(PageArray)#363 (7) { ["hooks"]=> array(2) { ["PageArray::render"]=> string(60) "MarkupPageArray->renderPageArray() in MarkupPageArray.module" ["PageArray::renderPager"]=> string(56) "MarkupPageArray->renderPager() in MarkupPageArray.module" } ["count"]=> int(3) ["items"]=> array(3) { [0]=> string(44) "/de/adressen/adressdaten/familientreff-bern/" [1]=> string(50) "/de/adressen/adressdaten/muetterzentrum-bern-west/" [2]=> string(45) "/de/adressen/adressdaten/stiftung-idee-sport/" } ["total"]=> int(3) ["start"]=> int(0) ["limit"]=> int(0) ["selectors"]=> string(38) "template=adress_daten, adr_rubrik=1273" } object(PageArray)#363 (7) { ["hooks"]=> array(2) { ["PageArray::render"]=> string(60) "MarkupPageArray->renderPageArray() in MarkupPageArray.module" ["PageArray::renderPager"]=> string(56) "MarkupPageArray->renderPager() in MarkupPageArray.module" } ["count"]=> int(3) ["items"]=> array(3) { [0]=> string(44) "/de/adressen/adressdaten/familientreff-bern/" [1]=> string(50) "/de/adressen/adressdaten/muetterzentrum-bern-west/" [2]=> string(45) "/de/adressen/adressdaten/stiftung-idee-sport/" } ["total"]=> int(3) ["start"]=> int(0) ["limit"]=> int(0) ["selectors"]=> string(38) "template=adress_daten, adr_rubrik=1273" } var_dump($list) where field is empty: no output.
  7. Hm, I don't think so. At the moment the code looks like this. if($page->adr_rubrik->count()){ $rubrik = $page->adr_rubrik; $out .= '<table id="myTable" class="tablesorter adressliste display"> <thead> <tr> <th class="inst">Institution</th> <th class="plz">PLZ</th> <th class="ort">Ort</th> <th class="inst_info">Beschreibung</th> </tr> </thead> <tbody>'; foreach($rubrik as $r) { $list = $pages->find("template=adress_daten, adr_rubrik=$r, include=all"); foreach($list as $l) { $out .= "<tr><td>"; I think the line in question IS above the table. Isn't it?
  8. Nope, no difference. Still output of the table head and end, where field is empty. Where the field has a category selected, rows are displayed as expected.
  9. Tried that. Now nothing at all is output, even where the field is not empty.
  10. Hello I have a template with a page reference field for categories. Now I'd like to list content from all the pages that have the same categories. My code looks like this: // list all addresses that have rubrik = adr_rubrik. $out = ""; if($page->fields->adr_rubrik) { $rubrik = $page->adr_rubrik; $out .= '<table id="myTable" class="tablesorter adressliste display"> <thead> <tr> <th class="inst">Institution</th> <th class="plz">PLZ</th> <th class="ort">Ort</th> <th class="inst_info">Beschreibung</th> </tr> </thead> <tbody>'; foreach($rubrik as $r) { $list = $pages->find("template=adress_daten, adr_rubrik=$r, include=all"); foreach($list as $l) { $out .= "<tr><td>"; if($l->adr_firma) $out .= "$l->adr_firma <br>"; if($l->adr_abteilung) $out .= "$l->adr_abteilung <br>"; if($l->adr_vorname) $out .= "$l->adr_vorname <br>"; if($l->adr_name) $out .= "$l->adr_name <br>"; if($l->adr_strasse) $out .= "$l->adr_strasse <br>"; if($l->adr_postfach) $out .= "$l->adr_postfach <br>"; if($l->adr_tel) $out .= "$l->adr_tel <br>"; if($l->adr_fax) $out .= "$l->adr_fax <br>"; if($l->adr_email) $out .= "$l->adr_email <br>"; if($l->adr_web) $out .= "<a target='_blank' href='$l->adr_web'>website</a> <br>"; if($l->adr_webzusatz) $out .= "<a target='_blank' href='$l->adr_webzusatz'>zusätzliche Website</a>"; $out .= "</td><td>"; $out .= $l->adr_plz; $out .= "</td>"; $out .= "<td>"; $out .= $l->adr_ort; $out .= "</td>"; $out .= "<td>"; $out .= $l->adr_beschreibung; $out .= "</td></tr>"; } } $out .= '</tbody></table>'; $content .= $out; } So far everything works fine. Except when the page reference field (adr_rubrik) has no pages selected. Then the output is a table without rows, i.e. the table head and end. What I like to have is, that nothing at all is being output if the field adr_rubrik is empty. Thanks for help.
  11. I now seem to have resolved the problem. While installing Horst's Module from above, I became aware, that there is also a textformatter module called "Newlines to XHTML line breaks". So far I used the php function nl2br() for displaying the content of the said field. I now removed that function and installed the "Newlines ..." module, and lo! it works! @Horst: So, your module is not even necessary. I appologize for the trouble I caused and I thank you for all your help.
  12. Thank you Horst. I'll give that a try. I am out of office at the moment. I'll tell you about the results as soon as possible.
  13. @Horst Yes, I did check that. Even when I write a number like this manually, it appears encoded in the frontend. The output looks like this: Note that even the space after the CAP is encoded. Whereas the textfield looks like this: @Christophe Yes, I did check and uncheck the encoder, with no results. How can I do this? It is a textarea field without editor. So there is no "HTML" button.
  14. Hello I have a textarea field without FCKEditor with the HTML Entity Encoder active. Now this leads to the problem, that the spaces in numbers (e.g. telephone numbers) appear encoded in the frontend. Like this: Is there a way to prevent this and keep the entity encoder active?
  15. Thanks tsdtsdtsd! Very good idea. Simple but beautyful.
  16. That doesn't suit my needs. I am about to transfer an existing site and I should keep the old structure. Which is: - old age - … -… -… - retirement -… -… -… - work -… -… - retirement -… -… -… You'll get the idea.
  17. Hello How do you handle this situation: There are two pages with identical content, like this: - old age - retirement - work - retirement Both pages "retirement" have identical content. URL should be like "/old_age/retirement/" and "/work/retirement/". Firstly, as far as I know, google doesn't like this at all. Secondly I don't want to maintain identical content on two pages.
  18. OK, I finally got it. Thank you very much for your good advice and endless patience.
  19. With notepad++ I saw, that the line endings were "\r". I changed these to "\r\n". Now it reads the lines correctly, print $csv[$i] in the loop shows 1 line. But I now get this error message:
  20. Sorry, been out of office … It prints out the whole file. The var_dump command dito, with «string(17236)» at the beginning. Edit: Like this: for($i = 0; $i < count($csv); $i++){ print $csv[$i]; if($i == 0) continue; // If first line are the column headlines $data = str_getcsv($csv[$i], "\t", '"'); // Change csv delimiter and quotes if needed it prints out the whole file. Like this: for($i = 0; $i < count($csv); $i++){ if($i == 0) continue; // If first line are the column headlines $data = str_getcsv($csv[$i], "\t", '"'); // Change csv delimiter and quotes if needed print $csv[$i]; It doesn't.
  21. Charset is UTF-8. I am working on a local xampp installation. I call the script via URL: localhost/website/import.php (this workes for other scritps like e.g. setting languages to active). And the csv file is in the root and readable. Still doesn't work … The file doesn't seem to be read. print $data[1]; after the str_getcsv command prints nothing.
  22. Hmm. Not quite there yet … I modified your code like this: <?php include("index.php"); // Read file $csv = file("angebote.csv", FILE_IGNORE_NEW_LINES); // $length = count($csv); // Loop over each line for($i = 0; $i < 1000; $i++){ $key = + $i; if($key == 0) continue; // If first line are the column headlines if($key == $length){ die("End of file!" . PHP_EOL); } $data = str_getcsv($csv[$key], "\t", '"'); // Change csv delimiter and quotes if needed // $data is an array of your csv data. e.g. array(1203, 1230) for your cat_adr.csv $addr = wire('pages')->get("adr_id=". $data[1]); $cat = wire('pages')->get("title=". $data[2]); $addr->of(false); $addr->adr_angebote = $cat; try { $addr->save(); } catch (Exception $e) { echo "$key: $e" . PHP_EOL; } // Prevent memory overflow wire('pages')->uncacheAll(); } I received the "End of file!" message. Apart from that, nothing happened. I suspect it has to do with $length. With print $length; I get "1". So it seems like there is only 1 line, which is not true. Or does it mean 1 file? So it doesn't read the file? "adr_id" is the name of the old address id, which is a five to six digit number with leading zeroes. So it's not an integer, is it? So i skipped the "(int)" from the code.
×
×
  • Create New...