Jump to content

diogo

Moderators
  • Posts

    4,296
  • Joined

  • Last visited

  • Days Won

    79

Everything posted by diogo

  1. You can provide a javascript variable to the javascript file by setting it in a <script> tag before including it. Like this: <style> var myXmlPage ='<?php echo $xmlPage->url; ?>'; <style> <script type="text/javascript" src="<?php echo $config->urls->templates?>scripts/main.js"></script> If you plan to provide more variables, you can create an object, so you don't overpopulate your global scope. <script> var myVariables = { xmlPage: '<?php echo $xmlPage->url; ?>', xmlPageTitle: '<?php echo $xmlPage->title; ?>' }; </script>
  2. I had less hours of sleep tonight fixing one functionality that I didn't test in incognito mode while developing a website. The site went live, and this functionality was not working for other users because some pages linked by a pageField were only accessible to the superuser. For me it always worked because I was logged in while testing it. Took me a long time to find out what was happening. Advice given
  3. 1. oh, makes sense... the line starts with <? so php must be trying to parse that. I don't know how to escape it, and don't have time to look for it now, so try simply this: <?php echo '<?xml version="1.0" encoding="UTF-8" ?>'; ?> 2. you need the path of the file on the server, or the absolute url? 3. See on the default site that comes with your PW install how this is done. Open the file head.inc, and see how javascript and css files are called there. edit: thanks kongondo
  4. Stephie, since you are here give processwire a ride, you won't be disappointed
  5. Makes sense to me. In that case you can create those child pages with the formats, and on that page template create the xml file as you would create an html file just making sure that you tell the browser that this is an xml file. You can do it like this: <?php header ("Content-Type:text/xml"); ?> <?xml version="1.0" encoding="UTF-8" ?> <xml_content> </xml_content> And inside the xml content, just use processwire tags normaly: <audio> <ogg_file><?php echo $page->ogg->url ?></ogg_file> <mp3_file><?php echo $page->mp3->url ?></mp3_file> </audio>
  6. $page->images->removeAll(); $page->save(); I used this on a single image field, and it didn't work at all. My guess is that it happens because in that case the field returns a single image and not an array, and removeAll() fails. After lots of head scratching (second time in this thread), and searching on the forums, I found this thread and managed to make it work based on my own advice fours posts above. How ironic is that, hein? $page->of(false); $page->image = $page->image->makeNew(); // <- added this $page->save(); $u = new WireUpload('pic'); $u->setMaxFiles(1); $u->setOverwrite(false); $u->setDestinationPath($page->image->path()); $u->setValidExtensions(array('jpg', 'jpeg', 'gif', 'png')); foreach($u->execute() as $filename) $page->image = $filename; $page->save();
  7. Hi wjkaluza. It's certainly possible to build the XML files in PW, but I'm wondering why you want them. You can build your pages normaly in PW and get all the raw data that you want from them, including raw files. Unless there is some hidden reason, I really don't see why you would build these XML files for one site that you will build yourself (not as an API to serve other sites). As an example: each group of files (mp3/ogg) (mp4/webm/ogv) could be a page (or repeater field) with two or three file fields under a common parent: - audio files -- audio 1 (mp3 and ogg files) -- audio 2 (mp3 and ogg files) -- audio 3 (mp3 and ogg files) - video files -- video 1 (mp4, webm and ogv files) -- video 1 (mp4, webm and ogv files) -- video 1 (mp4, webm and ogv files) You can then, reach them directly with the API or by using page fields on other pages. $myAudio = $pages->get(123) // reach the audio directly with the ID of the page $myAudio = $page->audio // or via a pageField on any other page To put a song on your page, you could do this, for example: <audio> <source src="<?php echo $myAudio->mp3->url; ?>" type='audio/mpeg; codecs="mp3"'> <source src="<?php echo $myAudio->ogg->url; ?>" type='audio/ogg; codecs="vorbis"'> Get a new browser, will you? </audio> This is just an example, there are many other ways to do this in PW. Edit: Another way would be to create a new fieldType that would allow the editor to upload one file in one of the formats, and convert it automatically to the other using something like FFmpeg https://github.com/alchemy-fr/PHP-FFmpeg
  8. By coincidence I'm working on a website that needs this feature (that's where the second tip from above came from). I also had the need to limit the selectable elements to those that were not selected yet by other pages. This is what I came up with: // this code goes on the "custom php" of the field settings // this field is included in the template "team", and the goal is to choose players for that team // players should be available (not selected yet by other teams) $players = $pages->find("template=player"); $teams = $pages->find("template=team, players.count!=0")->remove($page); // important to remove this page foreach($teams as $team) { foreach($team->players as $player) { $players->remove($player); // remove from our list the players that are in other teams } } return $players; edit: added "players.count!=0" to the teams selector. It's not my case, but if there are lots of teams this filter could make some difference.
  9. It is possible, this is the code you would use to get all pages that link to the current page from that field: $pages->find("related_pages=$page") You can even create a page field where you can select pages from all pages that link to the page you are editing. For this, just add this as the "custom php code to find selectable pages" on the "input field settings": return $pages->find("pageField=$page"); // where pageField is the name of the selectable pages template You should still define the parent or template of the selectable pages either on the code or on the other options from the field. <- forget the last part. The code overrides the previous options
  10. I'm not sure I understood completely your question, but i'll try to answer. My interpretation is that you have a page with four children, and you want a link to each of the children with a correspondent image taken from that children. This depends on how the limit from your image field. If the limit is "1" the field will return one image, and the url can be called with "$page->image->url". If the limit is different from one the field will return an array of images, and we would return the first image with "$page->images->first()->url" or "$page->images->eq(0)->url". I will assume the last case: echo "<ul>"; // go through all children of this page foreach ($page->children as $child) { echo "<li>"; // print the url of the current child on the loop as the target of the anchor element echo "<a href='{$child->url}'>"; // print the url of the first image on the current child as the source of the image element echo "<img src='{$child->images->first()->url}'>"; echo "</a>"; echo "</li>"; } echo "</ul>";
  11. Interesting solution for creating and managing Gists on Chrome https://chrome.google.com/webstore/detail/gistbox-desktop/pdjgfbgklbmmigkmmdbbhfchdldngkml
  12. Well, should be usable for whatever you want... of course you would have to take care of all the server side code.
  13. I love the favicon Edit: although I would love it even more if the sky would be transparent.
  14. Looks nice https://github.com/kenshin54/popline
  15. That page is the result of last years contest. Ok, that it's not the people's choice... but it's still the result of the exact same contest that we are talking about in this post
  16. diogo

    CMS Critic directory

    There's a brand new CMS directory at CMS Critic. Guess who's the highest rated http://www.cmscritic.com/dir/ edit: oops, I've just seen that Ryan made a quiet announcement here http://processwire.com/talk/topic/3987-cmscritic-development-case-study/?p=42437
  17. I have an example of the opposite http://www.cmscritic.com/critics-choice-for-best-free-cms-goes-to/
  18. Amazing work! thanks guys
  19. Hm, at this point I would say it's better that you go way back and forget this particular problem for now... One of the main ideas of processwire is that the software makes very few assumptions on what you want to do. So, you have to write code for almost anything, and that's the only way things will appear on the site. This is a great thing, since it allows you great flexibility with easy to write code (I can assure you this), but you can't expect to do things with point and click. So, my advice is that you learn how all this works before jumping into more particular things as the repeaters. Here are some links that can help you to start: http://wiki.processwire.com/index.php/Small_Project_Walkthrough <- best place to start http://processwire.com/api/ <- everything you need is here http://processwire.com/tutorials/ <- more tutorials http://cheatsheet.processwire.com/ <- you will love this one later
  20. I meant, what is the code that you wrote to output the info from the repeaters? Which by now I tend to think that there isn't any
  21. What's the code that you have for echoing the info from the repeater?
  22. Exactly what I thought. Not good to have something that subjective in a license. History taught us that many evil things happened based on this very same idea
×
×
  • Create New...