Can I do this?
{exp:weblog:entries weblog=$weblog['title']}I just get errors.
This is an archived forum and the content is probably no longer relevant, but is provided here for posterity.
The active forums are here.
July 13, 2009 2:00pm
Subscribe [2]#1 / Jul 13, 2009 2:00pm
Can I do this?
{exp:weblog:entries weblog=$weblog['title']}I just get errors.
#2 / Jul 13, 2009 2:06pm
No, you can’t do this. What are you trying to achieve?
#3 / Jul 13, 2009 2:07pm
I’m trying to build a hierarchical page navigation, I’ve been trying for the past 8 hours to do something that takes 2 lines of code in Wordpress. Starting to get slightly frustrated :(
The really annoying thing is I can see the admin side doing it perfectly when you view the Pages module.
#4 / Jul 13, 2009 2:14pm
you’ll probably have better luck leaving template tags out of the equation completely… just use php and $DB queries
#5 / Jul 13, 2009 2:15pm
Well, you can use PHP, just need to enable it and declare it properly. Try this on “Input”:
{exp:weblog:entries weblog="<?php echo $weblog['title'];?>"}Make sense? You probably need to declare the weblog array somewhere, too.
#6 / Jul 13, 2009 2:16pm
Well, you can use PHP, just need to enable it and declare it properly. Try this on “Input”:
{exp:weblog:entries weblog="<?php echo $weblog['title'];?>"}Make sense? You probably need to declare the weblog array somewhere, too.
This won’t work with my template as I have php generating the XML template everything is wrapped in php already, hence why I just want to use the variable.
What’s the point in allowing php in templates if you’re actually restricted in where you can use the php?
<?xml version="1.0" encoding="UTF-8"?>
<sections>
<?php
global $DB;
$query = $DB->query("SELECT site_pages FROM exp_sites WHERE site_id='1'");
if ($query->num_rows > 0) {
foreach($query->result as $row) {
$pages = unserialize($row['site_pages']);
$uris = $pages['uris'];
asort($uris);
foreach ($uris as $uri) {
echo "<item>";
echo "".$uri."</permalink>";
$segments = explode("/", $uri, -1);
$numSegments = sizeof($segments) - 1;
$weblogQuery = $DB->query("SELECT * FROM exp_weblog_titles WHERE url_title = '$segments[$numSegments]'");
if ($weblogQuery->num_rows > 0){
foreach($weblogQuery->result as $weblog) {
echo "<title>".$weblog['title']."</title>";
}
}
echo "</item>";
}
}
}
?>
</sections>
</sections>#7 / Jul 13, 2009 2:18pm
This won’t work with my template as I have php generating the XML template everything is wrapped in php already, hence why I just want to use the variable.
Well, you’d still need an actual “echo” statement, wouldn’t you?
#8 / Jul 13, 2009 2:21pm
No. If I put an echo statement there it won’t work. I just get php errors.
#9 / Jul 13, 2009 3:49pm
I’ll figure something out and when I do I’ll post it here.