K4RL Posted February 19, 2015 Posted February 19, 2015 I have been trying to pull info from specific articles as for instance the bellow will pull the data from the first article. It is how the 1x2x2 database template does it for the 1x article. {$data['records'][0]['breaking_news']} Sadly this has now changed and I have managed to recreate the 2x2 bit of the article template but I can not seem to find the correct way to pull the same data in the new version of pages. I know it can be done but I am pulling my hair out trying to figure it out. If anyone can please help it would be appreciated as it is my final stumbling block
Management Matt Posted February 20, 2015 Management Posted February 20, 2015 What is it you're trying to include?
K4RL Posted February 20, 2015 Author Posted February 20, 2015 If you look at the old 1x2x2 template for ip.content it shows the first post using the {$data['records'] [0] ['article_title']} to pull the latest article name etc,.. Since version 4 this has changed and I can not figure out how to do it. I have tried many variations but nothing seems to work and it is probably something really simple I have not grasped. I have built a rough template for the other posts which are in a {{foreach}} loop and I have them displaying and resizing lovely in both mobile and Desktop views but I am trying to rebuild the 1x article part at the top and unless I know how to pull the specific data then I am stumped. BTW thanks for sorting out that problem with the pagebuilder templates @Matt it now works flawlessly
K4RL Posted February 20, 2015 Author Posted February 20, 2015 On a side note as I have your attention and if anyone should know it would be you How would I offset the articles in the foreach loop by 1 so as not to have a duplicate of the first post?
K4RL Posted February 21, 2015 Author Posted February 21, 2015 Did you have any luck on working out how to do this @Matt
opentype Posted February 21, 2015 Posted February 21, 2015 Manually loading the first entry and then offsetting the rest sounds a little bit messy. I have a similar layout on my 4.0 front page: http://typography.guruWhat I did was to simply call a different template for the first record, but keeping the original loop. {{foreach $articles as $id => $record}} {{if ($id == 0)}} {template="entry" app="cms" location="database" group="article_template_first" params="$record, $database"} {{else}} {template="entry" app="cms" location="database" group="article_template_standard" params="$record, $database"} {{endif}} {{endforeach}}
K4RL Posted February 21, 2015 Author Posted February 21, 2015 Thanks for the help @opentype it is much appreciated. I have altered my index template in the pages template editor to the above code you posted. Then I created the two templates I placed the contents of the entry template into the newly created templates and altered the first template around a little as a tester. I am now getting error EX0 on my front page. Any help on this is appreciated as this is exactly what I am trying to do Many thanks for your input
K4RL Posted February 21, 2015 Author Posted February 21, 2015 I named the template above wrong and put article_database_first so recreated it as article_template_first but it still does not work my eyes are aching lol
K4RL Posted February 21, 2015 Author Posted February 21, 2015 Jeeees my stupidity today astounds me, just realised I have been creating the templates in the wrong place lolIt works a treat, I just need to do some messing now to get my bottom articles to display side by side again.Many thanks.
Recommended Posts
Archived
This topic is now archived and is closed to further replies.