Amazon API and Custom Fields
Posted: 18 July 2004 08:23 PM   [ Ignore ]  
Grad Student
Rank
Total Posts:  57
Joined  07-17-2004

Dear EE community,

I’ve been playing around with ideas for a “song of the day” sub-blog, and have signed up for the EE hosted trial to see if it might be a suitable platform to run such a thing.  The first hurdle I’ve encountered is that the Amazon API plugin seems not to be installed, and I seem unable to install it myself.  Assuming that gets sorted out, things are more complicated than I had figured.  Here are some of the problems my newbie, php-inexperienced self is coming up against.  Perhaps someone will have a suggestion.

First, I’ll explain my idea for the site:  every day, the site will feature a different song.  I’ll put about a week’s worth in the system at a time, and they will be automatically displayed on the relevant day as a kind of side-bar sub-blog.  That much seems easy enough.

I’ve created a number of custom fields for the sub-blog:  Song Title, Artist Name, Album Name, Album Release Date, Label, Song Description, Amazon Link, AllMusic Link.  Theoretically, I’ll be able to populate most of these fields using the Amazon API plugin.  Guess I’ll find out about that when/if it gets installed on the test server.

Here’s the first problem… I’d like the entry title dynamically generated by combining the custom fields {songtitle} / {songartist}.  Is that possible?  If so, I’ve not figured out how.  If I have to type these out manually, it wouldn’t be a huge deal, I just figure it’s potentially possible to automate it.

I’m currently playing with the categories functionality… I expect I’m going to have some questions about it, once I get a test up and running (which is difficult without access to the plugin!)

Thanks,

Matthew

Profile
 
 
Posted: 19 July 2004 09:36 AM   [ Ignore ]   [ # 1 ]  
Research Scientist
Avatar
RankRankRankRankRankRank
Total Posts:  5957
Joined  08-04-2002

Dynamically Generated Title…
If you are talking about this being done in the “title” field in the CP new entry form I doubt that’s possible.
If you are talking about creating a title from two custom fields when the entry is displayed on your site, that’s easily doable if I understand correctly.

As far as the Amazon API on your hosted demo...have you contacted Nevin at pMachineHosting.com to see if it can be installed for you?

Profile
 
 
Posted: 19 July 2004 06:41 PM   [ Ignore ]   [ # 2 ]  
Grad Student
Rank
Total Posts:  57
Joined  07-17-2004

Yes, I meant the former - the possibility to auto-fill the default “title” field for a given entry, not the page title.

They installed Amazon API on the hosted trial, but in the meantime, I had gotten impatient and installed it on my own host, which gives me greater flexibility anyway in terms of installing plugins myself and getting to designate specific upload directories, as well as trying to integrate other php scripts, although it also means a shorter trial period.

So, having played with the Amazon API, a few more questions.

First, I had intended to make a bunch of custom fields, and run separate Amazon API queries for each, so that I would (theorically) be able to sort by them.  That is to say, I made about ten custom fields (Artist, Album, Record Label, etc.) Testing this today, I didn’t have much luck.  I would use a bit of code like this in each custom field:

{exp:amazon:asin} {define_asin}B0002858YS{/define_asin}{amz_authors}{/exp:amazon:asin}

for the “artist” field.  When I posted the entry, it did not process the code at all, but rather just returned it exactly the same as it was typed.  Does this mean it’s not possible to execute commands like this from custom fields?  I also tried setting the ASIN as its own custom field and calling it within the other fields - which would be much, much easier, obviously - but it didn’t make a difference whether I hardcoded it or tried to set it dynamically - the above code wouldn’t work either way.

So I’ve decided that the easiest way to categorize the information is heirarchically within the a “music” group of categroies by band > album > song.  I’d like to make different templates for each heirarchical level - for instance, the band level should use a template that gives a brief band bio, a link to the band’s official site, and a list of all the items on the next level down - each album, sorted by release date, if possible.

The album page should have a quick review of the album, the relevant affiliate links, and all the “songs of the day” that have been featured on my site, listed either chronologically (date the song was featured on the site) or by track number - I haven’t decided which.  (I guess it would be a lot easier to do it chronologically...?)

Is there a way to automate this?  In other words, can I tell EE that if it’s a top level category (in this case, a band page) it should use a certain template, and if it’s one level down (an album page), it should use another template, and so on for three levels (well, four, really, since there should be a main “music” page that lists all the bands...)

So, the two questions for this post:

1.  Is it possible to execute code like the Amazon API snippet I posted above from within a custom field?  If so, where am I going wrong?

and

2.  Can I assign templates automatically based on the heirarchical level of a category?

Thanks,

Matthew

Profile
 
 
Posted: 19 July 2004 10:36 PM   [ Ignore ]   [ # 3 ]  
Research Scientist
Avatar
RankRankRankRankRankRank
Total Posts:  5957
Joined  08-04-2002

First of all, I could be wrong so I hope someone will step in and correct me if I am grin
----------
1)...Does this mean it’s not possible to execute commands like this from custom fields?
You can’t run EE code from within your content fields like you have it...as far as I’ve read. Instead, you would just put the asin number in the custom field and the rest in your template and call the custom field(s) in the template code.
2)...Can’t answer that but I seem to recall a different thread where someone was doing something similar. There seems to be quite a few people doing music/band related sites grin

Profile
 
 
Posted: 20 July 2004 07:56 PM   [ Ignore ]   [ # 4 ]  
Research Scientist
Avatar
RankRankRankRankRankRank
Total Posts:  9868
Joined  06-19-2002

1. As, PXLated stated, you can’t have EE tags/Plugin tags executed from within an entry field.  The tags need to be in your Template.

So, let’s say that you create a custom field to hold the ASIN and name it “asin”.  So the field can be accessed via “{asin}” in your Templates.  (One thing to note here is that you’ll want to be sure and set the formatting for that field to “none”.) Then in your Template you could use this:

{exp:weblog:entries ..... }

  {exp
:amazon:asin}
    {define_asin}{asin}{
/define_asin}
    {amz_authors}
  {
/exp:amazon:asin}

{
/exp:weblog:entries}

2. I’m afraid I don’t understand what you’re asking with that question.

 Signature 

Chris Curtis
chriscurtis.org

Profile
 
 
   
 
 
Post Marker Legend
New Topic New posts Hot Topic Hot Topic with new posts New Poll New Poll Moved Topic Moved Topic Sticky Topic Sticky topic
Old Topic No new posts Hot Old Topic Hot Topic with no new posts Old Poll Old Poll Closed Topic Closed Topic Announcement Announcements
Theme
Change Theme
Visitor Statistics
The most visitors ever was 1149, on July 16, 2007 10:33 AM
Total Registered Members: 60694 Total Logged-in Users: 43
Total Topics: 73124 Total Anonymous Users: 28
Total Replies: 394381 Total Guests: 545
Total Posts: 467505    
Members ( View Memberlist )