Jump to content

Faisal

Members
  • Posts

    70
  • Joined

  • Last visited

Everything posted by Faisal

  1. Hello every body I am starting my first project with ProcessWire for one of my websites newsflames.com But not only that! Moving from simple code I have made to ProcessWire must also add value even this is only changing system step. One of the new features I am planing to add in this step is to add multi language so the main categories structure wold be: (English is default language in homepage and it's categories) Home / -Politics /politics/ - Sports /sport/ - Arabic /ar/ -- Politics /ar/politics/ -- Sports /ar/sport/ - French /fr/ -- Politics /fr/politics/ -- Sports /fr/sport/ And so on.. All categories in website: (Politics Sports Business Health Technology Science) but in this example I use 2 I have download ProcessWire 2.3 from this site and after I install languages modules and tray all the ways I found in this site *note. there is no check boxes! But if I download the zip file from github it's all there plus some other stuff I think. However I still need to add content/pages in languages other than default (English) because some local news that in native language only! So I can't have English as mandatory! simple Example: Home - Politics -- Yahoo! News -- Fox News - Arabic -- Politics -- Yahoo! News -- 123 News - French -- Politics -- Yahoo! News -- abc News And so on.. So I came up with this and I wold say it's all there in PW, I did not invent any thing just for start duplicate the basic-page.php in to category.php and language-home.php and add theme from admin area and assign template with pages: Home -Politics category template - Sports category template - Arabic language-home template -- Politics category template -- Sports category template - French language-home template -- Politics category template -- Sports category template And so on.. I am using default installation with default profile in this example In my case I want the main categories in the top of the page so lets change the topnav Find in head.inc <ul id='topnav'><?php // Create the top navigation list by listing the children of the homepage. // If the section we are in is the current (identified by $page->rootParent) // then note it with <a class='on'> so we can style it differently in our CSS. // In this case we also want the homepage to be part of our top navigation, // so we prepend it to the pages we cycle through: $homepage = $pages->get("/"); $children = $homepage->children; $children->prepend($homepage); foreach($children as $child) { $class = $child === $page->rootParent ? " class='on'" : ''; echo "<li><a$class href='{$child->url}'>{$child->title}</a></li>"; } ?></ul> Change to: <ul id='topnav'><?php // Create the top navigation list by listing the children of the homepage. // If the section we are in is the current (identified by $page->rootParent) // then note it with <a class='on'> so we can style it differently in our CSS. // In this case we also want the homepage to be part of our top navigation, // so we prepend it to the pages we cycle through: if ($page->rootParent == "1006") { // Arabic page ID $homepage = $pages->get("/ar/"); // Arabic page URL } elseif ($page->rootParent == "1008") { // French page ID $homepage = $pages->get("/fr/"); // French page URL } else { $homepage = $pages->get("/"); // Homepage URL } $children = $homepage->children("template=category"); // show only pages using template category foreach($children as $child) { $class = $page === $child ? " class='on'" : ''; echo "<li><a$class href='{$child->url}'>{$child->title}</a></li>"; } ?></ul> Simple if condition but it's better to do something else like array or maybe add a field or maybe use the page URL to identity what and where? I don't know for now Now a simple language list and we going to use the subnav style for this example but this time will copy it instead of changing it Add this cod any where in the sidebar $defaultlang = $pages->get("/"); // Homepage URL $languages = $pages->find("template=language-home"); // show only pages using template language-home echo "<ul id='subnav' class='nav'>"; $languages->prepend($defaultlang); // display default language in the list foreach($languages as $language) { $class = $language === $page->rootParent ? " class='on'" : ''; echo "<li><a$class href='{$language->url}'>{$language->title}</a></li>"; } echo "</ul>"; It works just fine except that if you are in an English sub page like /sports the English link class will not be on (problem only in default language that if you want the css effects) // $class This may not be good for you if you plan to go back later for the great language module especially for large data! I only have 6 pages for every language plus news sources and all the news is cached but not saved so I can go back to use languages modules any time I want in this website Fell free to ask any thing about this If you can help improve or have any ideas please do
  2. Hi What is the triple equals stand for? what happen if only 2 i see no different behavior in localhost I see in default profile template $class = $child === $page->rootParent ? " class='on'" : ''; I try to dig it up but cod not find any thing Thanks
  3. Thank you owzim! and for all who liked my post
  4. Hello ProcessWire community At first I like to thank and congratulate Ryan for this wonderful work and I wished that I knew Ryan a long time ago And by the way you look awesome in the overview video Ryan And now a little bet about me: My name is Faisal Halwan from Saudi Arabia. I work in web development over 14 years now, and have dealt with various content management systems and PHP scripts in general. I was always dreamed of a flexible content management system for use in almost anything or what is now called CMF or allow me to say ProcessWire Thank you Ryan, you make my dream came true Yet I couldn't find any result in for any Arabic article talking about ProcessWire I will do my best to present ProcessWire and provide support in Arabic as soon as possible. Thank you and keep up the good work
×
×
  • Create New...