-
Posts
11 -
Joined
-
Last visited
Everything posted by maxa11an
-
module Module: ConfigurationForm (multiple fields container)
maxa11an replied to OLSA's topic in Module/Plugin Development
Yes, I just read that! I'll dig into solving that ? -
module Module: ConfigurationForm (multiple fields container)
maxa11an replied to OLSA's topic in Module/Plugin Development
Really like this module, using it to make a visual builder however I encountered that the uploading of files doesn't work. No errors is thrown. It starts the ajax-upload but when it should be done it just disappear and the file isn't uploaded. Currently debugging the issue. Will get back as soon as I find the issue. But also wanted to see if anyone else encountered this? -
I'm sorry if this have been asked before... I'm trying to make a way to enable only uploading (of images) for a specified user role - this is working! I might have missed this part, but is there any possibility to get the uploader's user information from an specific image that the user has uploaded?
-
Well even that did not seem to work, so I attach the $label in the function. Thanks for the help, and this is the result. Any way to make it better? <?php include("./head.inc"); /** * News template, the base part! * * By Max Allan Niklasson */ $tagQuery = $sanitizer->text($input->get->tag); $label = array( 'altTag' => 'Bild', 'postedUnder' => 'Postad under', 'readMore' => 'Läs mer »»', 'published' => 'Publicerad den', 'by' => 'av', 'prev' => 'Föregående', 'next' => 'Nästa', 'tagExpl' => 'Filtrering av nyheter med taggen: <em>'.$tagQuery.'</em>, visar %s träff(ar) av %s träff(ar). <br/> <a href="'.$page->url().'">Visa alla nyheter</a>' ); /** Here I have one issue when set $limit = 1, the pager don't work... Solution? **/ $limit = 3; //To fix the pager $start = ($sanitizer->text($input->get->page) ? $limit * $sanitizer->text($input->get->page) - $limit : 0); function thumbGet(Page $page, $label =null){ if($page->images){ $image = $page->images->first(); if($image){ if($image->width() > 250){ $thumb = $image->size(250); }elseif($image->height() > 250){ $thumb = $image->size(0, 250); }else{ $thumb = $image; } $return = "\n\t\t\t\t\t\t\t\t". '<div class="news-image">'. "\n\t\t\t\t\t\t\t\t\t". '<img src="'.$thumb->url().'" alt="'.$label[altTag].'" />'. "\n\t\t\t\t\t\t\t\t\t". '<p>'.$image->get('description').'</p>'. "\n\t\t\t\t\t\t\t\t". '</div>'; return $return; }else{return false;} } else{ return false; } } function processNewsItem(Page $news, Users $users, $label){ $writer = $news->createdUser; $tags = split(',',$news->news_tags); echo "\n\t\t\t\t\t".'<div class="news-item">'; echo "\n\t\t\t\t\t\t".'<h2>'.$news->title.'</h2>'; echo "\n\t\t\t\t\t\t\t".'<p>'; echo "\n\t\t\t\t\t\t\t\t".'<div class="news-summary">'.$news->summary.'</div>'; if(thumbGet($news)){ echo thumbGet($news, $label); } echo "\n\t\t\t\t\t\t\t".'</p>'; if($tags[0]){ echo "\n\t\t\t\t\t\t\t". "<div class='news-info'>"; echo $label[postedUnder].": "; $tagCount = 0; foreach($tags as $tag){ if($tagCount != 0) {echo ' | ';} echo "\n\t\t\t\t\t\t\t\t". '<a href="?tag='.$tag.'">'.$tag.'</a>'; $tagCount++; } echo "\n\t\t\t\t\t\t\t\t". '<div class="news-published">'.$label[published].': '.date("Y-m-d \k\l\. H:i:s", $news->created).' '. $label[by] .' '.$writer->name.'</div>'; echo "\n\t\t\t\t\t\t\t". '</div>'; } echo "\n\t\t\t\t\t\t\t".'<div class="news-read-more">'. "\n\t\t\t\t\t\t\t\t".'<a href="'.$news->url.'">'.$label[readMore].'</a>'. "\n\t\t\t\t\t\t\t".'</div>'; echo "\n\n\t\t\t\t\t".'</div> <!-- news-item -->'; } function pagination(PageArray $cPages, PageArray $tPages, $limit, $label){ //The URL fix $input = wire("input")->get; $sanitizer = wire("sanitizer"); $URL = ($sanitizer->text($input->tag) ? '?tag='.$sanitizer->text($input->tag).'&page=#NR#' : '?page=#NR#'); //The Totally number of pages $tot = $tPages->count(); $pages = round(($tot / $limit) + 1); if($tot <= $limit){ }else{ echo '<ul class="news-pager">'; if($pages <= $sanitizer->text($input->page) && 0 < ($sanitizer->text($input->page) -1) ){ echo '<li><a href="'.str_replace('#NR#', ($sanitizer->text($input->page)-1), $URL).'">'.$label[prev].'</a>'; } for($i = 1; $i <= $pages; $i++){ $class = ''; if($sanitizer->text($input->page) == $i){ $class = 'class="active"'; }elseif($sanitizer->text($input->page) == 0 && $i == 1){ $class = 'class="active"'; } echo '<li '. $class .'><a href="'.str_replace('#NR#', $i, $URL).'">'.$i.'</a>'; } if($pages >= $sanitizer->text($input->page) && $pages >= ($sanitizer->text($input->page) +1) ){ echo '<li><a href="'.str_replace('#NR#', ($sanitizer->text($input->page)+1), $URL).'">'.$label["next"].'</a>'; } echo '</ul>'; } } ###### Let's Print it out! ####### /** The viewer from tag query **/ if($tagQuery){ $counter = $page->children('template=news.article, news_tags*='.$tagQuery.', sort=-date, sort=-id '); $newsItems = $page->children('template=news.article, news_tags*='.$tagQuery.', sort=-date, sort=-id, start='.$start.', limit='.$limit); if($newsItems->count()) { printf($label->tagExpl, $newsItems->count(), $counter->count() ); echo "\t\t\t\t".'<div class="news-list">'; foreach($newsItems as $news){ processNewsItem($news, $users, $label); } echo "\n\n\t\t\t\t".'</div><!-- news-list -->'; } }else{ /** The Normal News viewer **/ $counter = $page->children('template=news.article'); $newsItems = $page->children('template=news.article, sort=-date, sort=-id, start='.$start.', limit='.$limit); if($newsItems->count()) { echo "\t\t\t\t".'<div class="news-list">'; foreach($newsItems as $news){ processNewsItem($news, $users, $label); } echo "\n\n\t\t\t\t".'</div><!-- news-list -->'; } } pagination($newsItems, $counter, $limit, $label); include("./foot.inc");
-
Well I've tried to make it global, but it results in a empty array... I gues I need to pass it over then...
-
No it's a variable created by me (in top of the script).
-
Thank's for the reply! It worked perfect at PW variables but on (for example) $label, it didn't work. Any solution or expl. on why?
-
Today I tried to create a News feed, and I think it became pretty good! But there is one problem, I have marked it in the code - so if anyone have a clue, tell me! This one requires two template; news.root (title) and news.article(title, body, summary, news_tags[comma separated values], images[optional]). CSS: .news-item .news-image{ width:250px; border:1px solid #CCC; text-align:center; vertical-align:middle; padding-top:2px; display:block; } .news-item .news-summary{ width:auto; } .news-item .news-image p{ padding:1px; margin:0px !important; text-align:center !important; } .news-item .news-read-more{ text-align:right; } .news-item .news-read-more a{ color:#373737 !important; } .news-item .news-read-more a:hover{ background:none !important; text-decoration:underline !important; } .news-item{ border-bottom:.4px dashed #CCC; } .news-item p{ text-align:left; } .news-pager { clear: both; margin: 1em 0; font-family: Arial, sans-serif; } .news-pager li { display: inline; list-style: none !important; list-style-type:none !important; margin: 0; } .news-pager li a, .news-pager li.separator { display: block; float: left; padding: 2px 9px; color: #fff; background: #2f4248; margin-right: 3px; font-size: 10px; font-weight: bold; text-transform: uppercase; } .news-pager li.active a, .news-pager li a:hover { color: #fff; background: #db1174; text-decoration: none; } .news-pager li.separator { display: inline; color: #777; background: #d2e4ea; padding-left: 3px; padding-right: 3px; } the news.root.php template <?php include("./head.inc"); /** * News template, the base part! * * By Max Allan Niklasson */ $tagQuery = $sanitizer->text($input->get->tag); $label = (object) array( 'altTag' => 'Bild', 'postedUnder' => 'Postad under', 'readMore' => 'Läs mer »»', 'published' => 'Publicerad den', 'by' => 'av', 'prev' => 'Föregående', 'next' => 'Nästa', 'tagExpl' => 'Filtrering av nyheter med taggen: <em>'.$tagQuery.'</em>, visar %s träff(ar) av %s träff(ar). <br/> <a href="'.$page->url().'">Visa alla nyheter</a>' ); /** Here I have one issue when set limit = 1, the pager don't work... Solution? **/ $limit = 3; //To fix the pager $start = ($sanitizer->text($input->get->page) ? $limit * $sanitizer->text($input->get->page) - $limit : 0); function thumbGet(Page $page, $label){ if($page->images){ $image = $page->images->first(); if($image){ if($image->width() > 250){ $thumb = $image->size(250); }elseif($image->height() > 250){ $thumb = $image->size(0, 250); }else{ $thumb = $image; } $return = "\n\t\t\t\t\t\t\t\t". '<div class="news-image">'. "\n\t\t\t\t\t\t\t\t\t". '<img src="'.$thumb->url().'" alt="'.$label->altTag.'" />'. "\n\t\t\t\t\t\t\t\t\t". '<p>'.$image->get('description').'</p>'. "\n\t\t\t\t\t\t\t\t". '</div>'; return $return; }else{return false;} } else{ return false; } } function processNewsItem(Page $news, $label, Users $users){ $writer = $news->createdUser; $tags = split(',',$news->news_tags); echo "\n\t\t\t\t\t".'<div class="news-item">'; echo "\n\t\t\t\t\t\t".'<h2>'.$news->title.'</h2>'; echo "\n\t\t\t\t\t\t\t".'<p>'; echo "\n\t\t\t\t\t\t\t\t".'<div class="news-summary">'.$news->summary.'</div>'; if(thumbGet($news, $label)){ echo thumbGet($news, $label); } echo "\n\t\t\t\t\t\t\t".'</p>'; if($tags[0]){ echo "\n\t\t\t\t\t\t\t". "<div class='news-info'>"; echo $label->postedUnder.": "; $tagCount = 0; foreach($tags as $tag){ if($tagCount != 0) {echo ' | ';} echo "\n\t\t\t\t\t\t\t\t". '<a href="?tag='.$tag.'">'.$tag.'</a>'; $tagCount++; } echo "\n\t\t\t\t\t\t\t\t". '<div class="news-published">'.$label->published.': '.date("Y-m-d \k\l\. H:i:s", $news->created).' '. $label->by .' '.$writer->name.'</div>'; echo "\n\t\t\t\t\t\t\t". '</div>'; } echo "\n\t\t\t\t\t\t\t".'<div class="news-read-more">'. "\n\t\t\t\t\t\t\t\t".'<a href="'.$news->url.'">'.$label->readMore.'</a>'. "\n\t\t\t\t\t\t\t".'</div>'; echo "\n\n\t\t\t\t\t".'</div> <!-- news-item -->'; } function pagination(PageArray $cPages, PageArray $tPages, $label, $limit, $sanitizer, $input){ //The URL fix $URL = ($sanitizer->text($input->get->tag) ? '?tag='.$sanitizer->text($input->get->tag).'&page=#NR#' : '?page=#NR#'); //Calculate number of matches that should be viewing $calc = $cPages->count(); //The Totally number of pages $tot = $tPages->count(); $pages = round(($tot / $limit) + 1); if($tot <= $limit){ }else{ echo '<ul class="news-pager">'; if($pages <= $sanitizer->text($input->get->page) && 0 < ($sanitizer->text($input->get->page) -1) ){ echo '<li><a href="'.str_replace('#NR#', ($sanitizer->text($input->get->page)-1), $URL).'">'.$label->prev.'</a>'; } for($i = 1; $i <= $pages; $i++){ $class = ''; if($sanitizer->text($input->get->page) == $i){ $class = 'class="active"'; }elseif($sanitizer->text($input->get->page) == 0 && $i == 1){ $class = 'class="active"'; } echo '<li '. $class .'><a href="'.str_replace('#NR#', $i, $URL).'">'.$i.'</a>'; } if($pages >= $sanitizer->text($input->get->page) && $pages >= ($sanitizer->text($input->get->page) +1) ){ echo '<li><a href="'.str_replace('#NR#', ($sanitizer->text($input->get->page)+1), $URL).'">'.$label->next.'</a>'; } echo '</ul>'; } } ###### Let's Print it out! ####### /** The viewer from tag query **/ if($tagQuery){ $counter = $page->children('template=news.article, news_tags*='.$tagQuery.', sort=-date, sort=-id '); $newsItems = $page->children('template=news.article, news_tags*='.$tagQuery.', sort=-date, sort=-id, start='.$start.', limit='.$limit); if($newsItems->count()) { printf($label->tagExpl, $newsItems->count(), $counter->count() ); echo "\t\t\t\t".'<div class="news-list">'; foreach($newsItems as $news){ processNewsItem($news, $label, $users); } echo "\n\n\t\t\t\t".'</div><!-- news-list -->'; } }else{ /** The Normal News viewer **/ $counter = $page->children('template=news.article'); $newsItems = $page->children('template=news.article, sort=-date, sort=-id, start='.$start.', limit='.$limit); if($newsItems->count()) { echo "\t\t\t\t".'<div class="news-list">'; foreach($newsItems as $news){ processNewsItem($news, $label, $users); } echo "\n\n\t\t\t\t".'</div><!-- news-list -->'; } } pagination($newsItems, $counter, $label, $limit, $sanitizer, $input); include("./foot.inc"); But there is one thing that I wonder about, is it necessary to attach ($label, $sanitizer, $input etc.) in the function? When I tried global but it didn't work...
-
Thanks! Well, I must say, very good CMS framework! Now I have changed and cleaned! <?php /** * Image gallery v.0.2 template * named bildgalleri.php * Created by Max Allan Niklasson a.k.a. rödgladan * Share and use! */ $labels = (object) array( 'subAlbums' => 'Album under', 'subPictures' => 'Foton under', 'prev' => 'Föregående', 'next' => 'Nästa', 'thumbs' => 'Miniatyrer' ); //breakLine after x-numbers loops function ImageGallery(Page $page,$breakLine=4){ $return_alb = Array(); $return_img = Array(); $numberImages = count($page->images); $numberPages = count($page->children); //Process the albums for($i = 0;$i < $numberPages;$i++){ //To find sub images use this $subPage = $page->children('template=bildgalleri')->eq($i); //To just get the informationen of the relative sub gallery $nextPage = $page->children('template=bildgalleri')->eq($i); //The thumb to this gallery $cover = $subPage->images->first(); if(!$cover){ //If no sub images is find, digg! $coverIsDef = false; //Search of childed images, and take the first found image while($coverIsDef===false){ $whileSubPage = $subPage->children('template=bildgalleri')->first(); $cover = $whileSubPage->images->first(); if($cover) $coverIsDef = true; else $subPage = $whileSubPage; } } if($cover){ //When images is found, make thumb of it $coverThumb = $cover->size(140,140); } $linebreak = 0; if($i > 0 && $i % $breakLine == 0) $linebreak = 1; $ret = (object) Array( url => $nextPage->url, title => $nextPage->title, cover => $coverThumb->url, name => $nextPage->name, description => $nextPage->summary, linebreak => $linebreak ); array_push($return_alb,$ret); } //Process images for($i = 0;$i < $numberImages;$i++){ $image = $page->images->eq($i); $thumb = $image->size(140,140); $linebreak = 0; if($i > 0 && $i % $breakLine == 0) $linebreak = 1; $ret = (object) Array( url => '?img='.$image->name, thumb => $thumb->url, description => $image->description, linebreak => $linebreak ); array_push($return_img,$ret); } return (object) array(albums => $return_alb, images => $return_img); } function singleImage(Page $page,$image){ $images = $page->images; $image = $images->get($image); $nextImage = $image->getNext(); $prevImage = $image->getPrev(); $sizedImage = $image->size(900); if($image) return (object) array( next_image => '?img='.$nextImage->name, prev_image => '?img='.$prevImage->name, url => $sizedImage->url, description => $image->description ); } /* * * * And now, print! * * */ include("./head.inc"); echo '<link rel="stylesheet" type="text/css" href="'.$config->urls->templates.'styles/bildgalleri.css" />'; echo '<div id="bodycopy-100">'; if(!$_GET['img']){ $gallery = ImageGallery($page,3); echo "<p class='image-gallery-desc'>{$page->summary}</p>"; //Get subgalleries if($gallery->albums){ echo '<h3>'.$labels->subAlbums.' <i>'.$page->title.'</i></h3>'; echo '<table class="image-table"><tr>'; foreach($gallery->albums as $album){ echo "<td><a href='".$album->url."'><img src='{$album->cover}' alt='".$album->name."' title='".$album->description."' /><p class='table-desc'>{$album->title}</p></a></td>"; if($album->linebreak == 1) echo "</tr><tr>"; } echo "</tr></table>"; } //Get images to this gallery if($gallery->images){ echo "<h3>".$labels->subPictures." <i>".$page->title."</i></h3>"; echo '<table class="image-table"><tr>'; foreach($gallery->images as $image){ echo "<td><a href='".$image->url."'><img src='".$image->thumb."' title='".$image->description."' alt='".$image->description."' /></a></td>"; if($image->linebreak==1) echo "</tr><tr>"; } echo '</tr></table>'; } } //Image view of one image! else{ $image = singleImage($page,$sanitizer->name($input->get->img)); echo "<div class='image-gallery'>"; echo "<div class='image-controls'>"; echo "<table><tr>"; echo "<td class='image-prev'>".(!$image->next_image ? "<a href='".$image->next_image."'>":"").$labels->prev.(!$image->next_image ? "</a>":"")."</td>"; echo "<td class='image-thumbs'><a href='./'>".$labels->thumbs."</a></td>"; echo "<td class='image-next'>".(!$image->prev_image ? "<a href='?img={$nextImage->name}'>":"").$labels->next.(!$image->prev_image ? "</a>":"")."</td>"; echo "</tr></table>"; echo "</div>"; echo "<div class='image-viewer'>"; echo "<img src='".$image->url."' />"; echo "<div class='image-description'>".$image->description."</div>"; echo "</div>"; echo "</div>"; } include("./foot.inc");
-
If I'm understand right, you want to have to different paginations? Like if I'm "standard-user" I'll see this [tt] -Home -About [/tt] And if I'm "premium-user" I'll see this [tt] -Home -About -Hidden for standards [/tt] Well, maybe you could make a if statement? I'll think this might work... Like this: if($user->hasRole('standard')){ //Your code to get the pages that have standards-permissions } elseif($user->hasRole('premium')){ //Your code to get the pages that have premium-permissions } else{ echo 'You dont have access to this'; }
-
Well, this is my first template to PW - this very nice CMS! It's a image gallery, that work with a simple admin-template, with current standard fields: -title -summary //little explanation of current gallery -headline -images So here is the template code -------------------------------------------------- <?php /** * Image gallery template * named bildgalleri.php * Created by Max Allan Niklasson a.k.a. rödgladan * Share and use! */ include("./head.inc"); echo '<style>'; echo '.image-gallery .image-controls{border-bottom:1px solid #CCC;}'; echo '.image-gallery-desc {padding-left:10px;font-style:italic;}'; echo '.image-gallery .image-controls a{color:#FF9494 !important;}'; echo '.image-gallery .image-controls table{width:100%;padding:0px !important; margin:0px !important; border-collapse:collapse;}'; echo '.image-gallery .image-controls table tr td{width:29.99%;}'; echo '.image-gallery .image-controls table tr td.image-prev{text-align:left;}'; echo '.image-gallery .image-controls table tr td.image-thumbs{text-align:center;}'; echo '.image-gallery .image-controls table tr td.image-next {text-align:right;}'; echo '.image-gallery .image-viewer {padding-top:30px; text-align:center;}'; echo '.image-gallery .image-description {font-style:italic;}'; echo '.image-table {border-collapse:separate;border-spacing:10px;}'; echo '.image-table tr td{padding:10px 10px 4px 10px!important;border:1px solid #DCDCDC;text-align:center;vertical-align:middle;}'; echo '.image-table tr td a:hover{background-color:transparent !important;}'; echo '.image-table tr td p.table-desc{margin:0px !important;color:#CCC;}'; echo '</style>'; if(!$_GET['img']){ echo "<p class='image-gallery-desc'>{$page->summary}</p>"; //Get subgalleries $numberPages = count($page->children); if($numberPages) { echo '<h3>Album under <i>'.$page->title.'</i></h3>'; echo '<table class="image-table"><tr>'; for($i = 0;$i < $numberPages;$i++){ //To find sub images use this $subPage = $page->children('template=bildgalleri')->eq($i); //To just get the informationen of the relative sub gallery $nextPage = $page->children('template=bildgalleri')->eq($i); //The thumb to this gallery $cover = $subPage->images->first(); if(!$cover){ //If no sub images is find, digg! $coverIsDef = false; //Search of childed images, and take the first found image while($coverIsDef===false){ $whileSubPage = $subPage->children('template=bildgalleri')->first(); $cover = $whileSubPage->images->first(); if($cover) $coverIsDef = true; else $subPage = $whileSubPage; } } if($cover){ //When images is found, make thumb of it $coverThumb = $cover->size(140,140); } //Write out the nice image whit link echo "<td><a href='{$nextPage->url}'> <img src='{$coverThumb->url}' alt='{$nextPage->summary}' width='{$coverThumb->width}' height='{$coverThumb->height}' /><p class='table-desc'>{$nextPage->title}</p> </a></td>"; } //Row break if($i > 0 && $i % 4 == 0){echo'</tr><tr>';} echo '</tr></table>'; } //Get images to this gallery $numberImages = count($page->images); if($numberImages){ echo "<h3>Foton under <i>".$page->title."</i></h3>"; echo '<table class="image-table"><tr>'; for($i = 0;$i < $numberImages;$i++){ $image = $page->images->eq($i); $thumb = $image->size(140,140); echo "<td><a href='?img={$image->name}'> <img src='{$thumb->url}' alt='{$thumb->description}' width='{$thumb->width}' height='{$thumb->height}' /> </a></td>"; //Row break if($i > 0 && $i % 4 == 0){echo'</tr><tr>';} } echo '</tr></table>'; } } //Image view of one image! else{ $images = $page->images; $image = $images->get($_GET[img]); $nextImage = $image->getNext(); $prevImage = $image->getPrev(); $sizedImage = $image->size(700); echo "<div class='image-gallery'>"; echo "<div class='image-controls'>"; echo "<table><tr>"; echo "<td class='image-prev'>".($prevImage != false ? "<a href='?img={$prevImage->name}'>":"")."Föregående".($prevImage != false ? "</a>":"")."</td>"; echo "<td class='image-thumbs'><a href='./'>Miniatyrer</a></td>"; echo "<td class='image-next'>".($nextImage != false ? "<a href='?img={$nextImage->name}'>":"")."Nästa".($nextImage != false ? "</a>":"")."</td>"; echo "</tr></table>"; echo "</div>"; echo "<div class='image-viewer'>"; echo "<img src='{$sizedImage->url}' />"; echo "<div class='image-description'>{$image->description}</div>"; echo "</div>"; echo "</div>"; } include("./foot.inc"); ----------------------------------------------------------- I also changed in the head.inc so the sub menu will not be printed if the template is "bildgalleri" (the name of my template). if($page->template != 'bildgalleri') Is there any way to clean it up, or ideas?