Jump to content

Recommended Posts

1st question... for some reason I'm throwing a 500 here and can't figure it out... I have double and triple checked all my brackets etc...


$user = JFactory::getUser();
$u = $user->username;
	date_default_timezone_set("America/New_York");
	$d = date("Y-m-d", time());

$xml = simplexml_load_data("modules/mod_holiday/assets/xml/Holidays.xml");
  foreach($xml as $key => $value){
    foreach ($value->events->event as $holiday) {
    
  	  If (($holiday['date']) == $d) { ?>
	   	
	   	<div id="CoverPop-cover" class="splash">
        <div class="CoverPop-content splash-center">
        <h2 class="splash-title"><? $holiday['name'] ?> <?= $u ?></h2>
        <p class="splash-intro">This is a test holiday</p>
        <p class="close-splash"><a class="CoverPop-close" href="#">Hit ESC to exit</a></p>
    </div> 
</div>
 
<?php 
    } 
   } 
    } ?>

2nd... I"m not sure I'm looping correctly so this is what I'm trying to do...

 

I'm trying to loop through the entire xml [located below here] and all I am after is the date and name fields... which I thought I was picking up but I could off on my loops...

Any suggestions would be greatly appreciated..

 

Thanks

John

<events>
<event>
<date>2015-02-12</date>
<name>New Year's Testing</name>
<flag_day>1</flag_day>
<url>http://en.wikipedia.org/wiki/New_Year%27s_Day</url>
<description>New Year's Day is observed on January 1, the first day of the year on the modern Gregorian calendar as well as the Julian calendar used in ancient Rome. With most countries using the Gregorian calendar as their main calendar, New Year's Day is the closest thing to being the world's only truly global public holiday, often celebrated with fireworks at the stroke of midnight as the new year starts. January 1 on the Julian calendar currently corresponds to January 14 on the Gregorian calendar, and it is on that date that followers of some of the Eastern Orthodox churches celebrate the New Year.</description>
</event>
<event>
<date>2015-01-01</date>
<name>New Year's Day</name>
<flag_day>1</flag_day>
<url>http://en.wikipedia.org/wiki/New_Year%27s_Day</url>
<description>New Year's Day is observed on January 1, the first day of the year on the modern Gregorian calendar as well as the Julian calendar used in ancient Rome. With most countries using the Gregorian calendar as their main calendar, New Year's Day is the closest thing to being the world's only truly global public holiday, often celebrated with fireworks at the stroke of midnight as the new year starts. January 1 on the Julian calendar currently corresponds to January 14 on the Gregorian calendar, and it is on that date that followers of some of the Eastern Orthodox churches celebrate the New Year.</description>
</event>
</events>
Link to comment
https://forums.phpfreaks.com/topic/294571-two-questions-here/
Share on other sites

Perhaps this is a copy/paste issue, but your code is missing an open PHP tag.

<?php   //<<< missing this tag
$user = JFactory::getUser();
$u = $user->username;
 
//...

Also, I would imaging the following

<? $holiday['name'] ?>

Should be

<?= $holiday['name'] ?>
Link to comment
https://forums.phpfreaks.com/topic/294571-two-questions-here/#findComment-1505609
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.