Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

  1. Index
  2. » How do I…?
  3. » stumped

#1 2009-07-21 18:04:37

kvnmcwebn
Member
From: Ireland
Registered: 2007-01-27
Posts: 724
Website

stumped

Someone who is much smarter than me enabled a motion section/page on my portfolio site to serve up different swf files attached to respective articles using only one flash object 2.0 header script. It takes the path from the article excerpt and pops it in. Heres the head script with the txp tags. By default this section landing page will play the “newhome.swf”.

<script type="text/javascript" src="/swfobject.js"></script>
		<script type="text/javascript">
			var flashvars = {};
			var params = {};
			var attributes = {};
<txp:if_individual_article>
   <txp:article form="motion_swf" />
<txp:else />
   swfobject.embedSWF("/newhome.swf", "flashwrap", "500", "331", "9.0.0", false, flashvars, params, attributes);</txp:if_individual_article>
</script>

Works great, here’s the page:
http://www.mcmonagledesign.com/motion/

I am trying to modify this script slightly in the blog section of my site to enable to detect whether the article has a swf or an image to display and then display the appropriate one.

I have tried a couple things and have not been able to get it working.

Here’s what I’m trying:

<script type="text/javascript">
			var flashvars = {};
			var params = {};
			var attributes = {};
<txp:if_individual_article>
   <txp:if_article_category name="blog_motion">
      <txp:article form="blog_swf" />
   <txp:else />
      <txp:article form="blog_entry_blog" />
   </txp:if_article_category>
<txp:else />
   <txp:article limit="1" form="blog_entry_blog"  status="5"  section="blog" />
   swfobject.embedSWF("/newhome.swf", "flashwrap", "500", "331", "9.0.0", false, flashvars, params, attributes);</txp:if_individual_article>
</script>

But because some articles don’t have flash then I have call up the article image from within the page itself inside the flashwrap div:
<div id="flashwrap"><txp:article_image /></div>

I really don’t need the default swf (newhome.swf) at all in this section.

I’m not sure how to modify the script to just disable flash altogether if the article only has an image.

Here’s the form “blog_swf” that places the path to the swf from the excerpt to the head script.

<txp:if_excerpt>swfobject.embedSWF("<txp:excerpt />", "flashwrap", "500", "331", "9.0.0", false, flashvars, params, attributes);</txp:if_excerpt>

Here’s what I’m using for the articles at the moment.

<txp:if_individual_article>
   <txp:if_article_category name="blog_motion">
      <txp:article form="blog_swf" />
   <txp:else />
      <txp:article form="blog_entry_blog"  />
   </txp:if_article_category>
<txp:else />
   <txp:article limit="1" form="blog_entry_blog"  status="sticky"  section="blog" />
</txp:if_individual_article>

here’s a page with a swf in the article:
http://www.mcmonagledesign.com/blog/polar-bear-at-the-zoo

not sure the best way to do this.

EDIT: altered formatting with bc. for readability

Last edited by Bloke (2009-07-21 21:16:34)


its a bad hen that wont scratch itself.
photogallery

Offline

#2 2009-07-21 20:56:30

jakob
Admin
From: Germany
Registered: 2005-01-20
Posts: 4,732
Website

Re: stumped

I’m not sure how to modify the script to just disable flash altogether if the article only has an image.

It’s a little difficult to follow your code without formatting (try bc.. for multiline code, then p. to resume normal text) but if I have understood you correctly, you only need flash when you have a path in your excerpt field. Could you not set the whole javascript section within your form blog_swf between your txp:if_excerpt tags and remove it from page template altogether, e.g.:

Have this in your page template:

<txp:if_individual_article>
    <txp:if_article_category name="blog_motion">
      <txp:article form="blog_swf" />
    <txp:else />
      <txp:article form="blog_entry_blog" />
    </txp:if_article_category>
<txp:else />
    <txp:article limit="1" form="blog_entry_blog" status="5" section="blog" />
</txp:if_individual_article>

and this would be blog_swf:

<txp:if_excerpt>
    <script type="text/javascript" src="/swfobject.js"></script>
    <script type="text/javascript">
       var flashvars = {};
       var params = {};
       var attributes = {};
       swfobject.embedSWF("<txp:excerpt />", "flashwrap", "500", "331", "9.0.0", false, flashvars, params, attributes);
    </script>
</txp:if_excerpt>

TXP Builders – finely-crafted code, design and txp

Offline

#3 2009-07-22 09:31:55

kvnmcwebn
Member
From: Ireland
Registered: 2007-01-27
Posts: 724
Website

Re: stumped

hi Jakob,
You mean put the blog_swf form in the head then right?
Good idea but it doesn’t work, but I will try and use if_excerpt in the page instead of the form.
Thanks a mill.
-kevin


its a bad hen that wont scratch itself.
photogallery

Offline

  1. Index
  2. » How do I…?
  3. » stumped

Board footer

Powered by FluxBB