开发者

Symfony 1.3.6 - javascript popup windw - how?

I am using SF 1.3.6. I have some static text files (HTML) that I want to be able to display in a popup window.

I tried this:

<a href="javascript:showPopup('foobar.html', 'all about foobar')">foobar<开发者_JAVA百科/a><br />

<script type="text/javascript">
function showPopup(url, title) {  window.open(url,title,"menubar=no,width=430,height=360,toolbar=no");} 
</script>

I get an sf404Exception when I click on the link. How may I fix this?

Note: I dont really want to write a route, and action and a template for these static files - is there another way to achieve popups with SF?

[Edit]

This is my original .htaccess content.

<IfModule mod_rewrite.c>
  RewriteEngine On

  #force everything to www so URLs look the same
  RewriteCond %{HTTP_HOST} ^example\.com$ [NC]
  RewriteRule ^(.*)$ http://www.example.com/$1 [R=301,L]

  # uncomment the following line, if you are having trouble
  # getting no_script_name to work
  #RewriteBase /

  # we skip all files with .something
  #RewriteCond %{REQUEST_URI} \..+$
  #RewriteCond %{REQUEST_URI} !\.html$
  #RewriteRule .* - [L]

  #redirect on trailing slash (otherwise, Symfony will 404)
  RewriteCond %{REQUEST_FILENAME} !-d
  RewriteRule ^(.*)/$ /$1 [R=302,L]

  # we check if the .html version is here (caching)
  RewriteRule ^$ index.html [QSA]
  RewriteRule ^([^.]+)$ $1.html [QSA]
  RewriteCond %{REQUEST_FILENAME} !-f

  # no, so we redirect to our front web controller
  RewriteRule ^(.*)$ index.php [QSA,L]
</IfModule>

I replaced it with Jeremy's script. I then restarted Apache but I am getting the same error

404 | Not Found | sfError404Exception Empty module and/or action after parsing the URL "/foobar.html" (/).


The default Symfony .htaccess file should have a line to serve files that already exist in the web directory. Make sure that the path your specifying for the file exists inside of web. Here's the relevant lines from .htaccess:

# we check if the .html version is here (caching)
RewriteRule ^$ index.html [QSA]
RewriteRule ^([^.]+)$ $1.html [QSA]
RewriteCond %{REQUEST_FILENAME} !-f

Here's my full .htaccess with some other improvements:

<IfModule mod_rewrite.c>
  RewriteEngine On

  #force everything to www so URLs look the same
  RewriteCond %{HTTP_HOST} ^example\.com$ [NC]
  RewriteRule ^(.*)$ http://www.example.com/$1 [R=301,L]

  # uncomment the following line, if you are having trouble
  # getting no_script_name to work
  #RewriteBase /

  # we skip all files with .something
  #RewriteCond %{REQUEST_URI} \..+$
  #RewriteCond %{REQUEST_URI} !\.html$
  #RewriteRule .* - [L]

  #redirect on trailing slash (otherwise, Symfony will 404)
  RewriteCond %{REQUEST_FILENAME} !-d
  RewriteRule ^(.*)/$ /$1 [R=302,L]

  # we check if the .html version is here (caching)
  RewriteRule ^$ index.html [QSA]
  RewriteRule ^([^.]+)$ $1.html [QSA]
  RewriteCond %{REQUEST_FILENAME} !-f

  # no, so we redirect to our front web controller
  RewriteRule ^(.*)$ index.php [QSA,L]
</IfModule>


Try adding a leading "/" to foobar.html.

javascript:showPopup('/foobar.html', 'all about foobar')

If you're in a dev environment, then calling foobar.html would actually be calling frontend_dev.php/foobar.html. Adding the leading "/" strips out the frontend_dev.php.


Where do you store your static files? To access them with /foobar.html you need to put 'em in the web/ directory.

Also, remember to make them readable by the web server.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜