Kirby snippet shows only 10 subpages - php

I'm working on this (NSFW), I created 12 subpages but only 10 are showing in the list.
I'm not using any limit() or pagination() in the snippet nor in the panel config, I can't find where this limit is regulated. My guess is a numbering issue, because if in the panel I drag up the 11th subpage up, anything below will not be displayed.
Any clue?
php:
<section id="entries">
<ul>
<li>
<div class="line asger">
<div class="text">00</div>
<div class="text bold">Asger Carlsen</div>
</div>
</li>
<?php $n = 1; foreach($pages->children()->visible()->sortBy('date', 'asc') as $entries): ?>
<li>
<div class="line">
<div class="text">0<?php echo $n++; ?></div>
<div class="table"><div class="text bold"><?php echo kirbytext($entries->title()) ?></div></div>
<div class="text"><?php echo kirbytext($entries->kind()) ?></div>
</div>
<div class="description hidden">
<?php echo kirbytext($entries->description()) ?>
</div>
<div class="left-half">
<img class="images hidden" src="<?php echo $entries->images()->first()->url() ?>" alt="<?php echo html($entries->title()) ?>" />
</div>
</li>
<?php endforeach ?>
</ul>
</section>
Folder structure: https://www.dropbox.com/s/8gigspwup0kwqei/Screenshot%202014-09-03%2015.39.51.png?dl=0

Your folder-structure is defiantly correct. You only could try to rename 04-2001 to something like 04-foo2001 but i don`t think that this causes your issue.
I had some quite similar behavior once. It was caused by image-metadata txt's that had the same name like the page-content txt's. So maybe it would be helpful if you show us your complete folder-structure including the files/filenames.
Next idea: Are you sure you have no invalid markdown in your txt's?
PS: This should be a comment, but i’m at 49 reputation, so i’m not allowed to comment ;) cheers!

It was probably a combination of .txt name conflict plus a missing image from a page.

Related

How to change css in php file

I am using post navigation for my blog. For this portion i wrote some css. It's working fine. But the problem is for the very latest post , it's showing blank space for next post link. Same thing is happened with oldest post, it's showing again bank space for previous post link.
I add code snippet for this portion. Can i anyone suggest how can i modify my css for this portion. Following code is embedded in php file.
<div class="row justify-content-center">
<div class="sewl-more-posts">
<div class="previous-post">
<?php If(previous_post_link()){?>
<span class="post-control-link">Previous Article</span>
<span class="post-name"><?php previous_post_link(); ?></span>
<?php } ?>
</div>
<div class="next-post">
<?php If(next_post_link()){?>
<span class="post-control-link">Next Article</span>
<span class="post-name"><?php next_post_link(); ?></span>
<?php } ?>
</div>
</div>
</div>
First, output the divs only if they'll have content:
<div class="sewl-more-posts">
<?php if (previous_post_link()){?>
<div class="previous-post">
<span class="post-control-link">Previous Article</span>
<span class="post-name"><?php previous_post_link(); ?></span>
</div>
<?php } ?>
<?php if (next_post_link()){?>
<div class="next-post">
<span class="post-control-link">Next Article</span>
<span class="post-name"><?php next_post_link(); ?></span>
</div>
<?php } ?>
</div>
This way, if the previous-post or next-post div is missing, you'll be able to target the remaining one with the :only-child pseudo class:
.sewl-more-posts > div:only-child {
text-align: center;
}
You cannot do this with php once the page is generated client-side, therefore you have to use javascript (for example):
onclick = documet.getElementById('the id you have').style.property = "blue";

Hide a tab with no content on a Magento EE product page

I have successfully added a tab to my view.phtml page located at app/design/frontend/enterprise/aps/template/catalog/product.
I tried an if statement to hide it if the Specifications field is empty, i.e. no content. The issue is, it doesn't work. It still shows the tab even if there is no content.
My code is below at the end of post.
2 Questions:
Am I taking the correct approach? Basically, I am making a tab to have an Expert Review tab. I originally was going to use a cms block, but figured purposing the Specifications field was easier, for one, but also I could ignore the tab if no content
Can you please help ? :)
Thanks so much and here is my code and I attached a screenshot of the empty tabs.
<div class="wa-product-details-tab product-description">
<div class="wa-product-details-tab-heading product-desc-tab">
<div rel=".wa-product-tab-details-item-1" class="wa-product-heading-item wa-product-heading-item-1 wa-product-heading-item-active">
<span>Description</span>
</div>
<div rel=".wa-product-tab-details-item-2" class="wa-product-heading-item wa-product-heading-item-2">
<span>Specs</span>
</div>
<div rel=".wa-product-tab-details-item-3" id="review-form" class="wa-product-heading-item wa-product-heading-item-3">
<?php
$summaryData = Mage::getModel('review/review_summary')
->setStoreId(Mage::app()->getStore()->getId())
->load($_product->getId());
?>
<span >Reviews (<?php echo $summaryData->getReviewsCount();?>)</span>
</div>
<div rel=".wa-product-tab-details-item-4" class="wa-product-heading-item wa-product-heading-item-4">
<span>APS Advisor Review</span>
</div>
</div>
<div class="wa-product-tab-details product-desc">
<div style="display: block;" class="wa-product-tab-details-item wa-product-tab-details-item-1">
<?php echo $_product->getDescription(); ?>
</div>
<div style="display: none;" class="wa-product-tab-details-item wa-product-tab-details-item-2">
<p> <?php echo $this->getChildHtml('additional')?></p>
</div>
<div style="display: none;" class="wa-product-tab-details-item wa-product-tab-details-item-3">
<p>
<?php echo $this->getChildHtml('review_form') ?>
<?php echo $this->getChildHtml('product_additional_data_review') ?>
</p>
</div>
<div style="display: none;" class="wa-product-tab-details-item wa-product-tab-details-item-4">
<?php if ($_product->getSpecifications()); ?>
</div>
</div>
I am not sure if I understood your issue correctly. I am assuming that you want to hide the "APS Advisor Review" tab if there is no content in it.
For this you can use an if condition to check if $_product->getSpecifications() has any content, and show the tab title only if there is any content like this
<?php if( !empty($_product->getSpecifications()) ){ ?> <!-- displays the tab title only if the product has any specifications -->
<div rel=".wa-product-tab-details-item-4" class="wa-product-heading-item wa-product-heading-item-4">
<span>APS Advisor Review</span>
</div>
<php } ?>

Displaying last 3 blog posts on wordpress custom theme

I have a custom theme I am working on in wordpress, and I want to display the last 3 blog posts made onto my home page. I also want to style certain information regarding each post differently, like have the month and year be a certain font, and the day be much bolder and different font as well, along with displaying like a sentence or less of the article, followed by a "..." and "read more" type of thing.
How do I pull data from the blog? I know there are certain wordpress functions that can get me this data but I haven't been able to quite figure out how to do it, I'm not really well versed in the wordpress php functions. Right now I just have it hard coded but it's annoying to have to retype everything when I make a new post. I know you can set to show however many blog posts on the settings->reading but I want to be able to fully customize how it looks.
Let me know any suggestions on how I should go about doing this!
<div class="bottom">
<div class="wrap-2">
<h2>Blog</h2>
<div class="content-div">
<div class="bottom_box">
<div class="btm-img"><h4>April <span>25</span><br />2014</h4></div>
<div class="right_block">
<p class="highlight2">blog title 1</p>
<p class="highlight3">lksj sldkf jsl lsdkfj sdklf sd</p>
Read More >
</div>
</div>
<div class="bottom_box">
<div class="btm-img"><h4>April <span>24</span><br />2014</h4></div>
<div class="right_block">
<p class="highlight2">blog title 2</p>
<p class="highlight3">lsdkjf lsdk fjsl dkkddk lsdkfjpaskldfj;</p>
Read More >
</div>
</div>
<div class="bottom_box">
<div class="btm-img"><h4>April <span>23</span><br />2014</h4></div>
<div class="right_block">
<p class="highlight2">blog title 3</p>
<p class="highlight3">lksdjf slkdfjsldkfj;as dfklsd;j fsld;kfj</p>
Read More >
</div>
</div>
</div>
</div>
</div>
Try the snippet below. Use your custom HTML block (the one with botom_box class) instead of this used below.
<?php $posts = get_posts("numberposts=3"); ?>
<?php if($posts) : ?>
<?php foreach( $posts as $post ) : setup_postdata( $post ); ?>
<!-- your HTML block goes here --->
<div class="post">
<h3><a href="<?php echo get_permalink($post->ID); ?>" ><?php echo $post->post_title; ?></a></h3>
<?php the_excerpt(); ?>" rel="bookmark">read more</a>
</div>
<!-- end of the HTML block -->
<?php endforeach; ?>
<?php endif; ?>

Php to auto populate grids

I have the following html code:
<div class="media row-fluid">
<div class="span3">
<div class="widget">
<div class="well">
<div class="view">
<img src="img/demo/media/1.png" alt="" />
</div>
<div class="item-info">
Title 1
<p>Info.</p>
<p class="item-buttons">
<i class="icon-pencil"></i>
<i class="icon-trash"></i>
</p>
</div>
</div>
</div>
<div class="widget">
<div class="well">
<div class="view">
<img src="img/demo/media/2.png" alt="" />
</div>
<div class="item-info">
This is another title
<p>Some info and details go here.</p>
<p class="item-buttons">
<i class="icon-pencil"></i>
<i class="icon-trash"></i>
</p>
</div>
</div>
</div>
</div>
Which basically alternates between a span class with the widget class, and then the widget class without the span3 class.
What I wanted to know was if there was a way to have php "echo" or populate the details for and details under the "item-info" class. Would I need to use a foreach statement to get this done? I would be storing the information in a mysql database, and while I can get it to fill in the info one by one (repeatedly entering the and echoing out each image and item title) it's not practical when the content needed to be displayed is over 15 different items. I'm not well versed in foreach statements so I could definitely use some help on it.
If someone could help me perhaps structure a php script so that it can automatically output the html based on the number individual items in the database, that'd be greatly appreciated!
I'm wondering if the html + php (not including the foreach) would look like this:
<div class="span3">
<div class="widget">
<div class="well">
<div class="view">
<img src="img/<? $file ?>" alt="" />
</div>
<div class="item-info">
<?$title?>
<p>Info.</p>
<p class="item-buttons">
<i class="icon-pencil"></i>
<i class="icon-trash"></i>
</p>
</div>
</div>
</div>
EDIT:
I wanted to add some more information. The items populated would be based on a type of subscription - which will be managed by a group id.
I was initially going to use <? (if $_SESSION['group_id']==1)>
echo <div class="item-info">
$title
<p>$info</p>
</div>
so that only the subscribed items would populate. But, I would need it to iterate through all the items for group1 table and list it. Currently I know that I can do
<? (if $_SESSION['group_id']==1)
while ($row=mysql_fetch_assoc($sqlItem))
{
$itemInfo = $row['info'];
$image = $row['image'];
$title = $row['title'];
$url = $row['url'];
};
>
$sqlItem for now can only be assigned one thing (manually - as in: $sqlItem = '123'), unless I iterate through which is what I'm trying to figure out.
Just read that 'mysql_fetch_assoc' is being depreciated with 5.5, here is the new way and looks better, easier I think.. Hope this helps, was updated today.
I hope this helps http://php.net/manual/en/mysqli-stmt.fetch.php
replace the printf with echo '//then your html stuff
This will iterate through the rows in your database until their are no more matching records.
shouldn't a while be enough? It depends on the structure of your database and website (we didn't need so much HTML I think. Some more PHP maybe). Hope this helps.

Drupal Block PHP

Im created a custom block, with the below code, but im having some trouble turning the Group Title into an link, that will take the user back to the group at anytime.
Below is the code ive used, I thought active turns it into a link, but perhaps im being stupid.
<div class="active"><h2><?php print $group_title; ?></h2></div>
Below is the full code:
<?php $group_title = og_get_group_context()->title; ?>
<?php $group_nid = og_get_group_context()->nid; ?>
<?php $forum_link = og_forum_get_forum_container($group_nid); ?>
<div class="active"><h2><?php print $group_title; ?></h2></div>
<div class="content"
<div class="item-list">
<ul>
<li class="user-input-link"><a title="Add a new Forum topic"href="/node/add/forum?gids[]=<?php print $group_nid; ?>">Add a new forum topic</a>
</ul>
</div>
</div>
You need to create URL for it to work.
Here is the link to API with more info: http://api.drupal.org/api/drupal/includes--common.inc/function/l/6
<div class="active"><h2><?php print l($group_title, "node/{$group_nid}"); ?></h2></div>
You need to do an anchor tag, like:
<div><h2><?php print $group_title; ?></h2></div>
I don't know how to get the url in Drupal though..

Categories