Jump to content

Search the Community

Showing results for tags 'php'.

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


Forums

  • Welcome to ProcessWire
    • News & Announcements
    • Showcase
    • Wishlist & Roadmap
  • Community Support
    • Getting Started
    • Tutorials
    • FAQs
    • General Support
    • API & Templates
    • Modules/Plugins
    • Themes and Profiles
    • Multi-Language Support
    • Security
    • Jobs
  • Off Topic
    • Pub
    • Dev Talk

Product Groups

  • Form Builder
  • ProFields
  • ProCache
  • ProMailer
  • Login Register Pro
  • ProDrafts
  • ListerPro
  • ProDevTools
  • Likes
  • Custom Development

Find results in...

Find results that contain...


Date Created

  • Start

    End


Last Updated

  • Start

    End


Filter by number of...

Joined

  • Start

    End


Group


AIM


MSN


Website URL


ICQ


Yahoo


Jabber


Skype


Location


Interests

  1. Not sure how to ask this, but basically I have an associative PHP array outputting a song ID and it's lyrics from PW using this code: It's being stored in the $lyricsArray variable <?php // Loop though album Tracks $numTracksContainingLyrics = 0; // How many contain lyrics? $lyricsArray = array(); // Create empty array to hold lyrics foreach ($albumTracks as $track) { $html = "<tr>"; $html .= "<td>"; $html .= "<a href='" . $track->song_file->url . "' class=''>" . $track->title . "</a>"; $html .= "</td>"; $html .= "<td>"; if ($track->lyrics != null) { // If lyrics field isn't empty $html .= '<a href="#" class="lyricCLicked" data-reveal-id="songID_' . $track->id . '">Lyrics</a>'; $numTracksContainingLyrics++; foreach ($track as $value) { $lyricsArray[$track->id] = $track->lyrics; } }; $html .= "</td>"; $html .= "<td>"; $html .= "<a href='#'>Buy</a>"; $html .= "</td>"; $html .= "</tr>"; echo $html; } ?> The PHP code for outputting those values mentioned above is below: What I'd like to do is also output the song title (commented in red in the code below). However, I don't know how to go about doing it using the simple arrays I have been constructing. <?php foreach ($lyricsArray as $key => $value) { $lyricModal = '<div id="songID_' . $key .'" class="reveal-modal small" data-reveal>'; $lyricModal = '<h2>' . //HOW DO I ALSO GET $track-title HERE??? . '</h2>'; $lyricModal .= $value; $lyricModal .= '<a class="close-reveal-modal">×</a>'; $lyricModal .= '</div>'; echo $lyricModal; } ?> Thank you for your help!
  2. Hi Forum, it seems as if I have a PHP question I'm unable to answer myself. I've tried for almost three hours now but I can't find the answer, why my code isn't working as it should. This is, what's going on: I have a central _functions.inc with this function: function renderReferenceList() { $page = wire('page'); $pages = wire('pages'); $page = $pages->get(1065); $page = $page->children("limit=15, sort=-date"); foreach($page as $child) { $out = "<div class='referenceTeaser post'>"; $out .= "<h3 class='articlehead'>{$child->headline}</h3>"; $out .= "<p>" . $child->summary . "<a href='{$child->url}'><i class='more'>Referenz ansehen</i></a></p>"; $out .= "</div>"; echo $out; } } Next I have a page template with this code: <?php include_once("./_functions.inc"); /** * Referenzen template * */ if ($page->id !== 1065) { $content = $page->body; $headline = $page->headline; $sectionhead = "Projekt"; $logo = $page->widget_logo; $logo = $logo ->single_image; $sidebar = "<div class='widget'>" . "<h2 class='sectionhead'>Kunde</h2>" . "<img class='logofile' src='{$logo->url}' title='$page->title' alt='$page->title' >" . "</div>"; } else { $sectionhead = "Referenzen"; $content = renderReferenceList(); } include("./_page.inc"); And I have a _page.inc with this code: <div id="main" class="grid-66 mobile-grid-100"> <?php echo "<h1 class='sectionhead'>$sectionhead</h1>"; if($headline) echo "<h2 class='articlehead'>$headline</h2>"; echo $content; ?> </div> <!-- /#main --> The problem is: The code for the else statement is working perfectly fine, it renders all div.referenceTeaser with the appropriate content, except that it does so on top of my markup directly after the opening body tag and not - as it should - within div#main ... var_dump($content=== null); returns true but no notice. What am I doing wrong? Thanks for your help before I'm going mad about this...
  3. I have a repeating loop which displays tracks from an album with a link on each track pointing to lyrics which appear in a popup window. Well, that's what I want to do at least Here's the code which displays the track listings: <?php // Show Album Tracks $albumTracks = $page->children; foreach ($albumTracks as $track) { $html = "<tr>"; $html .= "<td>"; $html .= "<a href='" . $track->song_file->url . "' class=''>" . $track->title . "</a>"; $html .= "</td>"; $html .= "<td>"; if ($track->lyrics != null) { // LYRICS LINK $html .= "<a href='#' data-reveal-id='lyricPopup'>Lyrics</a>"; }; $html .= "</td>"; $html .= "<td>"; $html .= "<a href='#'>Buy</a>"; $html .= "</td>"; $html .= "</tr>"; echo $html; } ?> The link is pointing to a modal popup div below: <div id="lyricPopup" class="reveal-modal" data-reveal> <h2><?php echo $track->title; ?></h2> <?php ?> <a class="close-reveal-modal">×</a> </div> What I need to do is have each track's lyrics popup in the modal. Can anyone supply the code for setting up the multi-dimension array which keeps tracks of which song title (lyric link) was clicked so that the appropriate lyrics for that particular song (associated with that song) appear in the modal? I understand the concept of arrays, but multidimensional are out my league. Knowing which link was clicked and retrieving the associated content for it is also beyond me. Not sure where to start. Thanks!!!
  4. Good morning, I'm working about a website made with Processwire, I don't know a lot about this CMS 'cause it's the first time I'm working with it. We have to change this website and when we try to use php in some template files (.php), it autocomment itself. Anyone has a solution about this, please? Thanks, Have a nice day
  5. non coders get sick with stupid simple problems like when to use curly brackets and when not. Is it php syntax or processWire syntax? I found: http://processwire.com/talk/topic/2682-drop-down-select-to-search-form/?p=26224 "Curly brackets only necessary if you've got two "->" in there" but http://processwire.com/talk/topic/1627-newbie-question-on-template-tags/?p=14916 <li><a$class href='{$child->url}'>{$child->title}</a></li> only one "->" in there... and http://processwire.com/api/variables/pages/ $skyscrapers = $pages->get("/cities/chicago/")->find("floors>=60, sort=floors"); two "->"s but no curlies... two hours trying to find out and no result... this is what I want to do: if($section->knots) { echo "<tr>"; echo "<td><p>$pages->get('/FixedData/')->knotsLang:</p></td>"; echo "<td><p>{$section->knots}</p></td>"; echo "</tr>"; }
  6. I recently found while doing work on Laravel a nice tool called Var Dumpling that will convert all var_dumps to nicely formatted blocks of text with a structure, making it a lot easier do debug var_dumps. It's available on Chrome and Firerox, you can see what it looks like on their page http://vardumpling.com/ Hope some of you find it interesting!
  7. Today i found a new, at least for me, kind of PHP-framework, which does look very promising. It may be a bit off topic for processwire, but for all programmers here that were using a framework like symfony or laravel, it could be a very interesting alternative. The project is called Phalcon and here is what they are saying about it: I have not used it myself, but not only the perfomance does look promising (from two to four times faster than every other PHP-framework), also the framework is feature-rich. It does not make assumptions about directory-structure. Have a look and tell me what you pros here think about it.
  8. Plase correct me if something is wrong, I'm still learning the processwire way xd. According to the API Docs http://processwire.com/api/variables/page/ $page->path The page's URL path from the homepage (i.e. /about/staff/ryan/) $page->url The page's URL path from the server's document root (may be the same as the $page->path) So I have to migrate a site from development to production server and all the links were messed up. Why? Because I was using $page->path for redirects. Changed redirects to $page->url and Presto! everything works fine. And, When to use $page->path? Use $page->path when importing other page. example $people = $pages->get('/system/people'); $friend = $pages->get($people->path . $input->urlSegment1); Use $page->url when you need a redirect $session->redirect($friend->url);
  9. Hello, I'm trying to create some pages programatically, nearly 2000. they have many fields and the server crashes before complete saving them. There's a way to save this pages by small amounts? Thanks!
  10. Hi all, I'm currently making a web app using ProcessWire. It will be in Danish and I am having trouble making the date render out in Danish. Any suggestions? Thanks!
  11. Hello, I'm a newbie in processwire. I have a problem : In my file head.inc, in the sidebar, there is a link : <a href="http://www."><div class="sidebar-block sidebar-corps"><?=$txt['espaceCorps']?></div></a> I want to change the text of the link (the text behind the <?=$txt['espaceCorps']?>, but I don't find where I can change that in the admin site, or in the code.... Any idea ? Thanks.
  12. Hello, My code seems to become quite messy very quickly when I do something... For example : $taskId = $input->post->task[$checked_player]; if ( $taskId != 0) { // Task selected // Get the task bonuses $task = $pages->get($taskId)->title; $new_XP = $pages->get($taskId)->XP; $new_HP = $pages->get($taskId)->HP; $new_GC = $pages->get($taskId)->GC; // Do the math $player->XP = $player->XP + $new_XP; $player->HP = $player->HP + $new_HP; $player->GC = $player->GC + $new_GC; } I feel like I'm using to many 'bridges' variables (I'm not sure this is clear)... Do you think the following would be better? : if ( $input->post->task[$checked_player] != 0) { // Task selected // Get the task bonuses $task = $pages->get($input->post->task[$checked_player])->title; $new_XP = $pages->get($input->post->task[$checked_player])->XP; $new_HP = $pages->get($input->post->task[$checked_player])->HP; $new_GC = $pages->get($input->post->task[$checked_player])->GC; // Do the math $player->XP = $player->XP + $new_XP; $player->HP = $player->HP + $new_HP; $player->GC = $player->GC + $new_GC; } Or even (not tested) : if ( $input->post->task[$checked_player] != 0) { // Task selected $task = $pages->get($input->post->task[$checked_player])->title; // Do the math $player->XP = $player->XP + $pages->get($input->post->task[$checked_player])->XP; $player->HP = $player->HP + $pages->get($input->post->task[$checked_player])->HP; $player->GC = $player->GC + $pages->get($input->post->task[$checked_player])->GC; } Is it just personal preferences or does it have a performance issue to use variables ? It may sound like a 'noob' question, and I know it's not specific to ProcessWire, but I felt like asking, so I know better ;-) Thanks! PS : I've just noticed there was a 'dev forum' for such questions! It should go there... But I guess that's too late... Sorry!
  13. Hi, Today I experienced a problem on my server, I could no longer create new files. The cause of this was the amount of files in the assets/sessions folder. The filesystem ran out of Inodes. My question is, shouldn't files in this folder be deleted automatically after some time? /Jasper
  14. Hi. I want to use the MixItUp script where I put the names category as filter. Basically, I need to achieve this: <script type="text/javascript"> $(function(){ $('#Grid').mixitup({ multiFilter: true, showOnLoad: 'category_1 category_2 category_3 category_4 category_5' }); }); </script> I use this code for getting the names category pages but, it adds an space at the first (generated by echo " " in order to separate the categories) that doesn't let to work correctly. <script type="text/javascript"> $(function(){ $('#Grid').mixitup({ multiFilter: true, showOnLoad: '<?php $categories = $pages->get("template=categories")->children("template=categories, sort=sort"); foreach($categories as $category){echo " ".$category->name;}?>' }); }); </script> With the above code I get this: <script type="text/javascript"> $(function(){ $('#Grid').mixitup({ multiFilter: true, showOnLoad: ' category_1 category_2 category_3 category_4 category_5' }); }); </script> Could somebody help me to avoid adding an space at the beginning of the first category? Thanks in advance Fernando
  15. I copies the Skyscrapers field entry data almost to the 'T' when creating my PW project. I created new pages/subpages for the drop down data to choose from and now I want to give a new page the option of selecting from one of those drop down of those categories. All looks good. I go from a drop down tree list of my pages, select the page I want to categorize the page with and then hit save ... but nothing stores in the database and when I come back I have to select it again. Also if I choose 'select' instead of PageListSelect I see a drop down containing nothing in the page when creating a new one. Is there some kind of programming needed to be able to store PageListSelect data? Thanks.
  16. I just started with PW and I've gotten the hang of things quite easily but whenever I make a new field it doesn't not appear on the user side of the template. I can manage the field content in the admin section but nothing appears but the title and body on the user side. Is there a permissions/roles function that I have to change? Is there something in the PHP template files I need to change? Thanks.
  17. Hi guys just moved from 34sp servers to lcn.com ones and as always something had to go wrong... transferred the db and files and linked up, everything worked until I tried logining in - I can't, no errors on the front end. I was also having trouble uploding images on some of my other sites So im guessing its a permissions issue just wondering what it might be, whether i just need to do something on .htacess or whether my hosting providerings can help. I hate sys admin Please any help would be great, Ben
  18. Hi, I have a question about PW. For developing totally custom applications/extensions, maybe parse some data from other site or whatever, you should need to build new module. I reckon modules are extensions to PW. It is said that PW is CMF (Content management framework), that shows when you use it's API. But is it also any kind of framework for PHP, that comes in handy, when developing custom applications? Such as is Codeigniter or CakePHP? Or must be code written in pure PHP? Thanks. Best regards, Franci
  19. My site has several pages that require access to one-off scripts the rest of the site doesn't use. To keep pages loading as fast as possible we don't load these scripts on every page. Instead, we typically include them on a per-page basis in an extra block loaded after the footer html. When I first started trying to port to PW I added textarea fields for "extra_head" and "extra_footer" into my primary template, and I hoped I could include these script loading directives in the "extra_footer" block and be off to the races. In fact, this would have worked beautifully if I had hard-coded paths for these scripts. There's the rub, however! I was trying to do things the PW way, so I used the php directives to get the path to my site's "templates" folder. When I output this "extra_footer" field in the page, the php doesn't get executed, so I never get the script path, and the whole thing fails. <script src="<?php echo $config->urls->templates?>static/js/jquery.isotope.js"></script> I don't know if I have output the field in my template the wrong way, so maybe there's some other php or api call that will cause it to actually interpret the code in this field during output? Here's what I have used: <?php echo $page->extra_footer; ?> I had this problem in other places, too. For example, during the port of the site we decided to start out with a "body" textarea that we bulk-dropped the html markup from the previous site into. This html had references to images and other static resources that we tried to access with the same type of php path reference as in the example above. Of course, none of it worked because that php code never gets executed. Is there a way to have the php in fields get executed during the page production? If not, is there some other reasonable way to get the path to site resources like scripts and general-purpose images (that wouldn't usually be included in a page's "images" field? Thanks, Rick
  20. Hi, I'm curious if anyone has implemented some sort of template ala twig, liquid, mustache, handlebars etc. so on and so forth? I noticed a blog post about blog themes which needed to be easier to work with than WP and using a simplified template syntax would definitely help for non-php-ers.
  21. Hi there, for some reason I do not succeed in doing a simple iteration (in this case with images): <?php $number_of_images = count($pages->get(1012)->images); foreach($pages->get(1012)->images as $image) { $thumbnail = $image->size(118,112); echo "<a href='{$image->url}'><img class='photo' src='{$thumbnail->url}' alt='{$image->description}' /></a>"; if ($number_of_images % 3 == 0) { echo "<p>Insert</p>";} } ?> In this case, there a 5 images attached to 1012, if I echo $number_of_images inside the foreach loop it prints "5". But on the other hand this variable doesn't react on my "$number_of_images % 3 == 0", meaning that it does not insert the <p>...-Chunk every 3 images. Can you help me to find the error in my approach or code? Thanks in advance! marcus
  22. hi forum, in my current project i'll have a very long faq-list (ul, li). thinking on how i could improve the usability of this list, i had the idea to provide an entry box on top of the list: as the user types into it, the list narrows itself depending on which letters are typed (example: if "a" is entered the list is filtered and only list-items starting with letter "a" are presented). does anyone of you has ever made something similar or knows a good route how to implement it? i would appreciate any hint. thanks in advance, christoph
  23. Hi! I'm working on my first processwire project and everything is working ok, but i have a question stuck in mi head: which is the "best" way to organize functions and stuff on php/processwire (is my first php project too). I have something like this: -- functions.inc -- home.php -- foo.php -- bar.php functions.inc have all the "get" functions that pull out content of the database, like: function getHomeNews($posts){ $out = array; foreach($posts as $post){ $out["name"] = $post->title; } return $out; } then in my home.php template i put a "render" function and do the echo thing to show the html on the front end: function renderHomeNews($posts){ foreach($posts as $post){ $name = $post{name}; $out = "<h1>{$name}</h1>" } } $news = $pages->find("template=news"); echo renderHomeNews($news); Suddenly a question comes to my mind, what if i put all the "render functions" of the project on renders.inc and all the "getter functions" on getters.inc, so the code on the template could be smaller and all the functions will be on just two files. That makes sense? is the same stupid thing? How do you organize your projects? Thanks!
  24. Hi, I want to process images being uploaded to PW by a client. Basically, making a sepia version of the images (with manual settings). I'm wondering: where's the best place/moment to implement this kind of process? Do you have any suggestions? FYI: I'm also using the cropping image tool by Antti Peisa. Here's my code. It loads the image, filters it and then overwrites it. $image = imagecreatefromjpeg('myimage.jpg'); // the original file imagefilter($image, IMG_FILTER_GRAYSCALE); imagefilter($image, IMG_FILTER_COLORIZE, 19, 18, 0); imagefilter($image, IMG_FILTER_BRIGHTNESS, -10); imagefilter($image, IMG_FILTER_CONTRAST, -2); imagejpeg($image, 'myimage.jpg'); // overwrites the original file. Thanks!
  25. hello forum, i assume i'm overlooking something very obvious, but can't get it. i try to output markup depending on whether a page has been checked as "featured" or not: <?php $featurednews = $pages->find("featured=1, template=gmk-news, limit=2, sort=-date"); ?> <?php if (!empty($featurednews)): ?> output my markup ... <?php endif; ?> this outputs my markup even if no page exists with featured=1 (checkbox checked). in other words it returns !empty = true or empty = false although the array must be empty. sorry if this is a dumb question, still newbie with php ... thanks for your help.
×
×
  • Create New...