ExpressionEngine CMS
Open, Free, Amazing

Thread

This is an archived forum and the content is probably no longer relevant, but is provided here for posterity.

The active forums are here.

Question about a query to relate weblogs

June 29, 2007 11:20am

Subscribe [3]
  • #1 / Jun 29, 2007 11:20am

    dolmance

    101 posts

    Hello, I need to query 2 weblogs and I’m confused about the best way to do it. The first one of my weblogs has some entries. The second one has relationship custom field that allows to select a weblog1 entry.

    Weblog 1
    Books
    Magazines
    Records

    Weblog2
    Frank Zappa, Records (relationship field)
    Capote, Books (relationship field)

    I’d like my page shows this information:

    Books > Capote
    Magazines >
    Records > Frank Zappa

    So, it should query weblog1 alphabetically and then extract related information from weblog2.
    I will appreciate any help with this.
    Thank you.

    [Mod Edit: Moved to how-to forum as its more appropriate]

  • #2 / Jun 29, 2007 11:51am

    Derek Jones

    7561 posts

    dolmance, if I’m understanding your setup, here’s a simplified example:

    {exp:weblog:entries weblog="weblog1" orderby="title" sort="asc"}
    
    <h2>{title}</h2>
    
    <p>{reverse_related_entries}<br />
        {title}</p>
    
    <p>{/reverse_related_entries}</p>
    
    <p>{/exp:weblog:entries}

  • #3 / Jun 29, 2007 11:54am

    ruraldreams

    279 posts

    Querying related weblogs is pretty complicated IMO, I’ve struggled with it a lot recently. 
    Here’s a thread with some info that helped me:
    http://ellislab.com/forums/viewthread/48695/
    but I found about half of the things I needed to do required PHP and not just the query module

  • #4 / Jun 29, 2007 12:30pm

    Derek Jones

    7561 posts

    Thanks ruraldreams, though it looks like Dolmance’s weblogs are setup with relationships already in a standard way that the regular EE tags can handle, which I’d certainly recommend.

  • #5 / Jun 29, 2007 12:43pm

    ruraldreams

    279 posts

    yeah, me too!  I saw query and related entries in the same post and jumped to conclusions

  • #6 / Jun 29, 2007 12:50pm

    dolmance

    101 posts

    Thanks Derek but your code doesn’t work as it gives this result:

    Books
    Magazines
    Records

    there are no related entries :(

  • #7 / Jun 29, 2007 12:55pm

    Derek Jones

    7561 posts

    Is the relationship field in weblog1 or weblog2?  It would seem best served in weblog2, but again, I do not know your data structure.

  • #8 / Jun 29, 2007 1:36pm

    dolmance

    101 posts

    The relationship is on weblog2

  • #9 / Jun 29, 2007 1:41pm

    Derek Jones

    7561 posts

    It should work as I have described, then.  Other things to look for are custom statuses, expired / future dated entries, etc.  If you want to email (not PM) Super Admin access to me, I can take a quick look at the data structure so I can give more targeted advice.

  • #10 / Jun 29, 2007 1:59pm

    dolmance

    101 posts

    OK, finally it worked on firefox. Safari was giving me an stupid error. I did it on a EE Pro. Does it work also on a EE Core?

  • #11 / Jun 29, 2007 2:05pm

    Derek Jones

    7561 posts

    What error?  There’s nothing browser specific about the code sample I gave you above.  The browser doesn’t affect what content ExpressionEngine outputs.  And yes, the Core version supports relationships identically to the licensed versions.

  • #12 / Jun 29, 2007 2:28pm

    dolmance

    101 posts

    This is the safari error:

    Safari can’t open the page “http://www.web.com/blog/news/”. The error was: “bad server response” (NSURLErrorDomain:-1011) Please choose Report Bug to Apple from the Safari menu, note the error number, and describe what you did before you saw this message.
     
    But don’t worry because I think it’s an htaccess problem.

    I’m trying that code on Core and it dosen’t work. It shows just the weblog1 entries. Any idea?

  • #13 / Jun 29, 2007 2:40pm

    Derek Jones

    7561 posts

    That error can occur if the script crashes, which can happen for instance if the memory usage exceeds the allotted amount on servers where PHP is being run as a CGI process.  It can also happen if .htaccess causes a loop, though, so yes, I would try eliminating that first.

    I cannot guess as to why it’s not working for you on Core.  The difference would have to be in your data, not the files.  How did the information get into your Core database?

  • #14 / Jun 29, 2007 7:22pm

    dolmance

    101 posts

    Both sites (Pro and Core) are very similar. I’ve checked the weblogs and custom field preferences and they are the same. I don’t know why it’s not working on Core :(
    Any other idea?

  • #15 / Jun 29, 2007 7:44pm

    Derek Jones

    7561 posts

    How did the information get into your Core database?  Are these imported?  Expired entries?  Future entries?  I cannot guess, dolmance, as you aren’t giving enough information or answering all of my questions.  My offer to log in and look stands, but the answer lies in your data itself, not in any preferences or things looking “very similar”.

.(JavaScript must be enabled to view this email address)

ExpressionEngine News!

#eecms, #events, #releases