Resolved - Add "Recent Posts" to Website
Is there a way to add "recent posts" to my website in the root from the bludit blog in the sub folder blog? Would like to have 5 recent posts from my blog show up on the website in my footer. Hope this makes sense.
Update: I found this https://docs.bludit.com/en/misc/embed-b ... websitedoc on using the api, but not sure how to style it or change the number of posts from 15 to 5.
Update: I found this https://docs.bludit.com/en/misc/embed-b ... websitedoc on using the api, but not sure how to style it or change the number of posts from 15 to 5.
Last edited by nootkan on Mon Apr 24, 2017 6:27 pm, edited 1 time in total.
I have built my website with dreamweaver cs6 and placed bludit inside a sub directory named "blog". I was able to follow the embed instructions and get the posts to show in my footer but I only wanted 5 posts not 15. I also can't figure out how to make some changes to the css to add padding between the "Title" and "Link to Post" text.
Below are screenshots of what I am seeing and what I want to change with css if possible. Changes are highlighted in a square box.
This is what I see using Firefox's Firebug extension:
Below are screenshots of what I am seeing and what I want to change with css if possible. Changes are highlighted in a square box.
This is what I see using Firefox's Firebug extension:
- Edi
- Site Admin
- Posts: 3121
- Joined: Sun Aug 09, 2015 5:01 pm
- Location: Zurich
- Has thanked: 54 times
- Been thanked: 77 times
- Contact:
You can limit the number of posts with a codition:nootkan wrote:I was able to follow the embed instructions and get the posts to show in my footer but I only wanted 5 posts not 15.
Code: Select all
$i = 1;
foreach($data as $post) {
if($i <= 5) {
$postPermalink = $post['permalink'];
echo $post['title'];
echo '<a href="'.$postPermalink.'">Link to post</a>';
echo '<br>';
$i++;
}
else {
break;
}
}
Add classes, and give them some CSS definitions:I also can't figure out how to make some changes to the css to add padding between the "Title" and "Link to Post" text.
Code: Select all
$i = 1;
foreach($data as $post) {
if($i <= 5) {
$postPermalink = $post['permalink'];
echo '<div class="post-title">'.$post['title'].'</div>';
echo '<a class="post-link" href="'.$postPermalink.'">Link to post</a>';
echo '<br>';
$i++;
}
else {
break;
}
}
Clickwork - Websites mit Bludit | Planet Bludit - Tipps und Snippets
Thanks for the reply however I am a complete newbie when it comes to php coding. I wouldn't know where to add the code you provided. I can copy and paste php but that is about all I can do with it for now. I was hoping that what I wanted to do was already an option with bludit and I just couldn't find it. Any plans to add these abilities to the api plugin in the future?
- Edi
- Site Admin
- Posts: 3121
- Joined: Sun Aug 09, 2015 5:01 pm
- Location: Zurich
- Has thanked: 54 times
- Been thanked: 77 times
- Contact:
What is the code you are using at the moment?
I don't know, if there are any plans for additions to the plugin.
I don't know, if there are any plans for additions to the plugin.
Clickwork - Websites mit Bludit | Planet Bludit - Tipps und Snippets
Thanks again for the reply. Here is the code I am using now based on the https://docs.bludit.com/en/misc/embed-b ... my-website:
Do I paste the codition code you posted somewhere inside this code?
Code: Select all
<div id="box8">
<h3>Archived Blog Posts</h3>
<?php
$url = 'http://www.mysite.com/blog/api/show/all/posts/9db3f4a23151d350951cb5e279cb4251';
$jsonData = file_get_contents($url);
$data = json_decode($jsonData, true);
foreach($data as $post) {
$postPermalink = $post['permalink'];
echo $post['title'];
echo '<a href="'.$postPermalink.'">Link to post</a>';
echo '<br>';
}
?></div>
- Edi
- Site Admin
- Posts: 3121
- Joined: Sun Aug 09, 2015 5:01 pm
- Location: Zurich
- Has thanked: 54 times
- Been thanked: 77 times
- Contact:
Yes, its an extension of the code you have posted (after the line "$data = json_decode($jsonData, true);").
The whole code is:
The whole code is:
Code: Select all
<div id="box8">
<h3>Archived Blog Posts</h3>
<?php
$url = 'http://www.mysite.com/blog/api/show/all/posts/9db3f4a23151d350951cb5e279cb4251';
$jsonData = file_get_contents($url);
$data = json_decode($jsonData, true);
$i = 1;
foreach($data as $post) {
if($i <= 5) {
$postPermalink = $post['permalink'];
echo '<div class="post-title">'.$post['title'].'</div>';
echo '<a class="post-link" href="'.$postPermalink.'">Link to post</a>';
echo '<br>';
$i++;
}
else {
break;
}
}
?>
</div>
Clickwork - Websites mit Bludit | Planet Bludit - Tipps und Snippets
Awesome thanks very much for this.
If I wanted to only have the title as a hyperlink instead of the "link to post" text how would I do that?
I tried the following changes but neither worked for me. The first one is close as it shows the title as a link but when I try to click it I can't. The second example just gives a blank page.
If I wanted to only have the title as a hyperlink instead of the "link to post" text how would I do that?
I tried the following changes but neither worked for me. The first one is close as it shows the title as a link but when I try to click it I can't. The second example just gives a blank page.
Code: Select all
$i = 1;
foreach($data as $post) {
if($i <= 5) {
$postPermalink = $post['permalink'];
echo '<a class="post-title">'.$post['title'].'</a>';
echo '<br>';
$i++;
}
else {
break;
}
}
Code: Select all
$i = 1;
foreach($data as $post) {
if($i <= 5) {
$postPermalink = $post['permalink'];
echo '<a class="post-link" href="'.$postPermalink.'"> ['title']</a>';
echo '<br>';
$i++;
}
else {
break;
}
}
- Edi
- Site Admin
- Posts: 3121
- Joined: Sun Aug 09, 2015 5:01 pm
- Location: Zurich
- Has thanked: 54 times
- Been thanked: 77 times
- Contact:
You can use:
"echo" is a sort of PHP function to show some output. HTML output is set between ' (quotation marks), if it is combined with variables the string has to be put together with . (dots).
Code: Select all
$postPermalink = $post['permalink'];
$postTitle = $post['title'];
echo '<a class="post-link" href="'.$postPermalink.'">'.$postTitle.'</a>';
echo '<br>';
Clickwork - Websites mit Bludit | Planet Bludit - Tipps und Snippets