Change menu link in flash site - php

I've got a flash site and php panel. It's xml file is dynamic. And i want add external link on a menu item.
E.G. News menu go to news.com
I found process.php in panel/application/controllers. With the following:
//News
if($lang == 'tr')
{
$nTitle = 'Haberler';
$nName = 'Haber Listesi';
}
else
{
$nTitle = 'News';
$nName = 'News List';
}
echo '<page>
<title><![CDATA['.$nTitle.']]></title>
<data>news</data>
'.$this->getpagebackground('news').'
<page>
<title><![CDATA['.$nName.']]></title>
<data>news_list</data>'.$nl;
$newsRs = $this->db->query("Select date_format(date,'%d.%m.%Y') date,content,content_en,id,title,title_en From news Where status = 10 Order By viewOrder Desc");
if($newsRs[0])
{
foreach($newsRs as $news):
if($lang == 'tr')
{
$nContent = $news->content;
$newsTitle = $news->title;
}
else
{
$nContent = $news->content_en;
$newsTitle = $news->title_en;
}
echo '<news>
<data>news_'.$news->id.'</data>
<title>'.$newsTitle.'</title>
<date><![CDATA['.$news->date.']]></date>
<sum>'.substr($nContent,0,150).'</sum>
<content><![CDATA[<p>'.$nContent.'</p>]]></content>'.$nl;
$newsGallery = $this->db->query("Select * From news_media Where status=10 And news_id=".$news->id);
if($newsGallery[0])
{
echo '<gallery>'.$nl;
foreach($newsGallery as $ng):
echo '<item>'.$ng->media.'</item>';
endforeach;
echo '</gallery>'.$nl;
}
echo '</news>'.$nl;
endforeach;
}
echo '</page>'.$nl;
Can i change link in here?

Related

Change class of a menuitem to active if page alias matches menu alias (in a foreach)

I got a simple sidemenu that is displayed using a foreach:
<?
if($contentcr[0]['catid'] == '9'){
foreach($pagecr as $page){
$landingnospace = str_replace(' ', '_', $page['alias']);
$title = $page['title'];
if($title != '') {
$contentje .= '<li>'.$title.'</li>';
}
}
echo $contentje;
}
else{
echo 'Alternatief sidemenu';
}
?>
The alias of the page is displayed in the url using .htaccess:
DirectoryIndex
RewriteEngine on
RewriteBase /_extern/website1/
#Indexes uitzetten
Options -Indexes
#Website1
RewriteRule ^(.*).html content.php?alias=$1 [L]
I am currently using two queries on the page, one for db_content and one for db_categories
db_content:
// content
$content = "SELECT * FROM `db_content` WHERE alias = '".$_GET['alias']."' ";
$contentcon = $conn->query($content);
$contentcr = array();
while ($contentcr[] = $contentcon->fetch_array());
db_categories
// Pages
$page = "SELECT con.title, con.alias, con.images, con.introtext
FROM db_content con
LEFT JOIN db_categories cat ON con.catid = cat.id
AND cat.alias = '".$_GET['alias']."' WHERE con.state = 1 ORDER BY `ordering` DESC";
$pagecon = $conn->query($page);
$pagecr = array();
while ($pagecr[] = $pagecon->fetch_array());
So how can I compare the results in the foreach to the alias in the url, and if they match add the class: current-menu-item to the list tag?
You could introduce a $class variable and see if the current $page["alias"] equals the $_GET["alias"]. If so, apply the class current-menu-item, if not, leave it blank.
<?
if($contentcr[0]['catid'] == '9'){
$alias = $_GET["alias"];
foreach($pagecr as $page){
$landingnospace = str_replace(' ', '_', $page['alias']);
$title = $page['title'];
if($title != '') {
// magic happens here
$class = ($page["alias"] == $alias)?"current-menu-item":"";
$contentje .= '<li><a class="'.$class.'" href="http://www.website.nl/_extern/website1/'.$landingnospace.'.html">'.$title.'</a></li>';
}
}
echo $contentje;
}
else{
echo 'Alternatief sidemenu';
}
?>

WordPress sidebar navigation based off of top-level parent page

I'm trying to create a complex sidebar navigation system that remains the same depending on what top-level page you're viewing. For example, say I have this navigation:
Home
About
Our Company
Location
Hours
Our PeopleJim
Dave
Sarah
Kelly
PortfolioLogos
Websites
Contact
Now, if the user was anywhere within the About section, I'd want the sidebar to display:
About
Our Company
Location
Hours
Our PeopleJim
Dave
Sarah
Kelly
That goes for if they're in the main About page, in the Our Company page, or in the Location page. I need the whole navigation visible regardless of depth.
If the user was in a page with no sub-items, such as Contact, the sidebar needs to show:
Home
About
Portfolio
Contact
What's more, the ordering needs to be based on a WordPress Menu (one main menu, each sidebar can't be it's own; that's too complicated for the user). I don't know if that complicates things or not.
In the past, I've managed to get something to display children and sibling pages, but it doesn't display parent pages, and doesn't display in the order that the user defines.
<ul>
<?
global $wp_query;
if( empty($wp_query->post->post_parent) ) {
$parent = $wp_query->post->ID;
}
else {
$parent = $wp_query->post->post_parent;
}
wp_list_pages ("&title_li=&child_of=$parent");
?>
</ul>
If this can be modified to work the way I want it, that'd be great. I'm going to try and figure this out on my own, and will post updates as I make progress.
UPDATE 1: I've made a bit of progress determining what the absolute parent is. I think I'm on the right track.
<?
if ($post->post_parent) {
$ancestors = get_post_ancestors($post->ID);
$root = count($ancestors)-1;
$parent = $ancestors[$root];
} else {
$parent = $post->ID;
}
echo "Current Page: " . $post->ID . "<br />";
echo "Top Level Parent: " . $parent;
?>
UPDATE 2: I can now determine the correct page ID to query for a menu, so I think I'm getting close.
<?
$children = get_pages("child_of=".$post->ID);
if ($post->post_parent) {
$ancestors = get_post_ancestors($post->ID);
$root = count($ancestors)-1;
$parent = $ancestors[$root];
} elseif (count($children) != 0) {
$parent = $post->ID;
} else {
$parent = 0;
}
echo "Current Page: " . $post->ID . "<br />";
echo "Top Level Parent: " . $parent;
?>
UPDATE 3: I'm nearly there! The only problem is this uses the page's order from the editor, not from the menu. Is it possible to edit this to work with a menu instead?
<aside>
<?
$children = get_pages("child_of=".$post->ID);
if ($post->post_parent) {
$ancestors = get_post_ancestors($post->ID);
$root = count($ancestors)-1;
$parent = $ancestors[$root];
$sidebarDepth = 0;
$postParentID = get_post($parent);
$title = $postParentID->post_title;
} elseif (count($children) != 0) {
$parent = $post->ID;
$sidebarDepth = 0;
$postParentID = get_post($parent);
$title = $postParentID->post_title;
} else {
$parent = 0;
$sidebarDepth = 1;
$frontPageID = get_option("page_on_front");
$exclude = $frontPageID;
$postParentID = get_post($frontPageID);
$title = $postParentID->post_title;
}
?>
<header>
<h6><? echo $title ?> »</h6>
</header>
<section>
<nav>
<?
echo "<ul>";
wp_list_pages("child_of=" . $parent . "&depth=" . $sidebarDepth . "&exclude=" . $exclude . "&title_li=&");
echo "</ul>";
?>
</nav>
</section>
</aside>
Figured it out! I modified the code from this answer to add a start_in option to wp_nav_menu, and modified my code from there. Now this works exactly as I wanted it.
In functions.php:
// add start_in argument to navigation
add_filter("wp_nav_menu_objects",'my_wp_nav_menu_objects_start_in',10,2);
function my_wp_nav_menu_objects_start_in( $sorted_menu_items, $args ) {
if (isset($args->start_in) && $args->start_in != 0) {
$menu_item_parents = array();
foreach ($sorted_menu_items as $key => $item) {
if ($item->object_id == (int)$args->start_in) $menu_item_parents[] = $item->ID;
if (in_array($item->menu_item_parent, $menu_item_parents)) {
$menu_item_parents[] = $item->ID;
} else {
unset($sorted_menu_items[$key]);
}
}
return $sorted_menu_items;
} else {
return $sorted_menu_items;
}
}
In page.php (or whatever template you want):
<aside>
<?
if ($post->post_parent) {
$ancestors = get_post_ancestors($post->ID);
$root = count($ancestors)-1;
$parent = $ancestors[$root];
} elseif (count(get_pages("child_of=".$post->ID)) != 0) {
$parent = $post->ID;
} else {
$parent = get_option("page_on_front");
$sidebarDepth = 1;
$exclude = $parent;
}
if ($post->post_parent || count(get_pages("child_of=".$post->ID)) != 0) {
$sidebarDepth = 0;
$start_in = $parent;
$depth = 0;
} else {
$depth = 1;
$start_in = 0;
}
$parentID = get_post($parent);
$parentTitle = $parentID->post_title;
$parentURL = get_permalink($parentID);
?>
<header>
<h6><? echo $parentTitle ?> »</h6>
</header>
<section>
<nav>
<?
wp_nav_menu(
array(
"container" => false,
"depth" => $depth,
"items_wrap" => '<ul>%3$s</ul>',
"start_in" => $start_in,
"theme_location" => "first"
)
);
?>
</nav>
</section>
</aside>

How To Add An RSS Feed To My Search.php file?

I'm running a social network and right now my search.php shows results for people, and tags. How can I add an RSS Feed? I own a blog and I wanted to add my RSS Feed to the search so whenever someone searches for a topic it will show up on the search page.
Here's the search.php code:
$feed = new feed();
$feed->db = $db;
$feed->url = $CONF['url'];
if(isset($_SESSION['username']) && isset($_SESSION['password']) || isset($_COOKIE['username']) && isset($_COOKIE['password'])) {
$verify = $loggedIn->verify();
if($verify['username']) {
$feed->user = $verify;
$feed->username = $verify['username'];
$feed->id = $verify['idu'];
if(isset($_GET['tag'])) {
$skin = new skin('shared/top'); $top = '';
$TMPL['theme_url'] = $CONF['theme_url'];
$TMPL['private_message'] = $verify['privacy'];
$TMPL['avatar'] = $verify['image'];
$TMPL['url'] = $CONF['url'];
$top = $skin->make();
}
}
}
$feed->per_page = $settings['perpage'];
$feed->time = $settings['time'];
$feed->censor = $settings['censor'];
$feed->smiles = $settings['smiles'];
$feed->c_per_page = $settings['cperpage'];
$feed->c_start = 0;
$feed->l_per_post = $settings['lperpost'];
$TMPL_old = $TMPL; $TMPL = array();
$skin = new skin('shared/rows'); $rows = '';
if(empty($_GET['filter'])) {
$_GET['filter'] = '';
}
// Allowed types
if(isset($_GET['tag'])) {
// If the $_GET keyword is empty [hashtag]
if($_GET['tag'] == '') {
header("Location: ".$CONF['url']."/index.php?a=welcome");
}
$hashtags = $feed->getHashtags(0, $settings['qperpage'], $_GET['tag'], null);
$TMPL['messages'] = $hashtags[0];
} else {
// If the $_GET keyword is empty [user]
if($_GET['q'] == '') {
header("Location: ".$CONF['url']."/index.php?a=welcome");
}
$TMPL['messages'] = $feed->getSearch(0, $settings['qperpage'], $_GET['q'], $_GET['filter']);
}
$rows = $skin->make();
$skin = new skin('search/sidebar'); $sidebar = '';
if(isset($_GET['tag'])) {
$TMPL['trending'] = $feed->sidebarTrending($_GET['tag'], 10);
} else {
$TMPL['genre'] = $feed->sidebarGender($_GET['filter'], $_GET['q']);
}
$TMPL['ad'] = generateAd($settings['ad6']);
$sidebar = $skin->make();
$TMPL = $TMPL_old; unset($TMPL_old);
$TMPL['top'] = $top;
$TMPL['rows'] = $rows;
$TMPL['sidebar'] = $sidebar;
if(isset($_GET['logout']) == 1) {
$loggedIn->logOut();
header("Location: ".$CONF['url']."/index.php?a=welcome");
}
$TMPL['url'] = $CONF['url'];
if(isset($_GET['tag'])) {
$TMPL['title'] = '#'.$_GET['tag'].' - '.$settings['title'];
} else {
$TMPL['title'] = $LNG['title_search'].' - '.$_GET['q'].' - '.$settings['title'];
}
$skin = new skin('shared/timeline_x');
return $skin->make();
Please help :)
Try this example
<?php
$articles = $pages->find('blog')->children()->visible()->flip()->limit(10);
snippet('feed', array(
'link' => url('blog'),
'items' => $articles,
'descriptionField' => 'text',
'descriptionLength' => 300
));
?>
link:
This is the main link in our feed, which takes the visitor back to our site. In this case we want them to get back to our blog, so we build an url to our blog with the url() helper function.
items:
As items for our feed, we pass the set of $articles we found in the first line. The feed snippet will automatically take care of getting the right info out of those $articles (like title, url, etc.)
descriptionField:
If you want to show a description for each item in your feed, you need to specify a field, which is available in any item and should be used for the description.
descriptionLength:
This is maximum number of characters the description will have. An excerpt is automatically generated by the feed snippet.

MySQL:Update (not uploading image)

Think of simple profile page. User must editing. So, I've created basic php page. But, it is doesn't upload image. Why is it not uploading? I don't understand.
<?php
if((array_key_exists("degistir",$_GET) && $_GET['degistir'] == "dogru") && (array_key_exists('uyeId',$_GET) && $_GET['uyeId'] == md5(#$_SESSION['uyeGiris_skype'])))
{
if(isset($_POST['duzenlemeBitir']))
{
$uyeUrl_ = "inc/imj/uye/".$_SESSION['uyeGiris_skype'];
if(!is_dir($uyeUrl_)){mkdir($uyeUrl_);
$profilResim = $uyeUrl."/".$FILES['profilResim']['name'];
move_uploaded_file($_FILES['profilResim']['tmp_name'],$profilResim) or die(mysql_error());
$galeri = array();
for($s=1; $s<9; $s++)
{
$uyeUrlLink = $uyeUrl_."/".$_FILES['galeri'.$s]['name'];
$uyeUrlAdi = $_FILES['galeri'.$s]['name'];
move_uploaded_file($_FILES['galeri'.$s]['tmp_name'],$uyeUrlLink) or die(mysql_error());
$galeri[$s] = $uyeUrlLink;
}
if(!isset($_FILES['profilResim']['value']))
{
$_FILES['profilResim']['value'] = $uyeDetay['profilResim'];
}
if(!isset($_FILES['galeri1']['value']))
{
$_FILES['galeri1']['value'] = $uyeDetay['galeri1'];
}
if(!isset($_FILES['galeri2']['value']))
{
$_FILES['galeri2']['value'] = $uyeDetay['galeri2'];
}
if(!isset($_FILES['galeri3']['value']))
{
$_FILES['galeri3']['value'] = $uyeDetay['galeri3'];
}
if(!isset($_FILES['galeri4']['value']))
{
$_FILES['galeri4']['value'] = $uyeDetay['galeri4'];
}
if(!isset($_FILES['galeri5']['value']))
{
$_FILES['galeri5']['value'] = $uyeDetay['galeri5'];
}
if(!isset($_FILES['galeri6']['value']))
{
$_FILES['galeri6']['value'] = $uyeDetay['galeri6'];
}
if(!isset($_FILES['galeri7']['value']))
{
$_FILES['galeri7']['value'] = $uyeDetay['galeri7'];
}
if(!isset($_FILES['galeri8']['value']))
{
$_FILES['galeri8']['value'] = $uyeDetay['galeri8'];
}
$ekle = mysql_query("UPDATE uye SET skype='".$_POST['skype']."', msn='".$_POST['msn']."', facebook='".$_POST['facebook']."', yas='".$_POST['yas']."', boy='".$_POST['boy']."', kilo='".$_POST['kilo']."', hakkinda='".$_POST['hakkinda']."', profil_resim='".$profilResim."', galeri_1='".$galeri[1]."', galeri_2='".$galeri[2]."', galeri_3='".$galeri[3]."', galeri_4='".$galeri[4]."', galeri_5='".$galeri[5]."', galeri_6='".$galeri[6]."', galeri_7='".$galeri[7]."', galeri_8='".$galeri[8]."' WHERE e_posta = '".$_SESSION['uyeGiris_ePosta']."' AND sifre='".$_SESSION['uyeGiris_sifre']."'") or die(mysql_error());
}
}
?>
Notice: This codes have mysql_error() functions but I can't see error the simple profil editing page..
Thank you for your interest.
Good works..
Clerical error..
$uyeUrl = blabla..
if(!is_dir($uyeUrl_)){mkdir($uyeUrl_);}
$profilResim = $uyeUrl_."/".$FILES['profilResim']['name'];

Populating accordion with database results help

I am building a system in which the user can build thre own navigation menu from a selection of catergories, the way it works is that is they click on 'Blog' they they can get an accordion titled 'Blog' and on expanding this they see all the blog titles, however as the moment, my application creates multiple accordions if there are multiple blog entries, so at the moment i have two blog entries and when the user slects 'Blog' they get to accordions, where as they should get one with all the titles in
Controller:
public function category($content_id) {
//$this->output->enable_profiler(TRUE);
if (intval($this->uri->segments[4])){
$content_id = $this->uri->segments[4];
} else {
$content_id = $this->uri->segments[7];
}
$data['content'] = $this->site_model->get_content($content_id);
$this->load->view("call", $data);
}
Model:
public function get_content($content_id) {
$this->db->select('*');
$this->db->from ('content');
$this->db->join('categories', 'categories.category_id = content.categories_category_id', 'left');
$this->db->where ('categories_category_id', $content_id);
$query = $this->db->get();
return $query->result_array();
}
View:
<?php
if(isset($content)) {
// var_dump($content);
foreach($content as $row) {
echo "<h2 class='$row[category_name]'><a href='#'>$row[category_name]</a></h2>";
echo "<div class='$row[category_name]'><a href='index.php/home/get_content/$row[content_id]' class='contentlink'>$row[content_title]</a></div>";
}
}
?>
How can I alter my code so for category the user selects only one accordion gets built put all the categories realted content is placed in that accordion?
Hope this makes sense.
If I understand correctly you should move the creation of the header out of your loop:
<?php
if(isset($content)) {
echo "<h2 class='$category_name'><a href='#'>$category_name</a></h2>";
foreach($content as $row) {
echo "<div class='$row[category_name]'><a href='index.php/home/get_content/$row[content_id]' class='contentlink'>$row[content_title]</a></div>";
}
}
?>
If you don't know the category name you could try something like this:
<?php
$first = true;
if(isset($content)) {
echo "<h2 class='$category_name'><a href='#'>$category_name</a></h2>";
foreach($content as $row) {
if ($first) {
echo "<h2 class='$row[category_name]'><a href='#'>$row[category_name]</a></h2>";
$first = false;
}
echo "<div class='$row[category_name]'><a href='index.php/home/get_content/$row[content_id]' class='contentlink'>$row[content_title]</a></div>";
}
}
?>

Categories