GithubHelp home page GithubHelp logo

Comments (11)

michael-milette avatar michael-milette commented on July 19, 2024

I apologize in advance - I hate it when people do this to me instead of answering my question - but I just have to ask...

Why would ARCHIVED pages be appearing in a news feed? The only answer I could come up with was if you had a "What's been recently archived" RSS feed.

Michael

from wet-boew-php.

upsonp avatar upsonp commented on July 19, 2024

I don't know a good way to change the title without it being specified at the top of the file. You could probably do it using JavaScript.

@michael-milette I don't think this is specific to the archived variable. I currently have my site setup using a boilerplate, content file setup. As an example:

Boiler Plate File


<?php 
    $_PAGE['lang1'] = "eng";
    $_PAGE['left_menu_gauche'] = $_SERVER['DOCUMENT_ROOT']."/otoliths/includes/menus/left-menu-gauche.php";
    $_PAGE['title_' . $_PAGE['lang1']]  = "Introduction";
    $_PAGE['issued'] = "2011-10-02"; 

    include_once $_SERVER['DOCUMENT_ROOT'] . "/templates/2-col-php-header-1.php";
?>

<!--custom metadata-->



<!--end of custom metadata-->

<?php include_once $_SERVER['DOCUMENT_ROOT'] . "/templates/2-col-php-header-2.php"; ?>

<!--custom css-->


<!--end of custom css-->

<?php include_once $_SERVER['DOCUMENT_ROOT'] . "/templates/2-col-php-header-3.php"; ?>

At the top of the boilerplate file I set my variables that are page specific. if this was an archived page there would also be a $_PAGE['isarchived'] == '1'; at the top under the $_PAGE['issued']. Most of the other stuff is set in the template files.

My /templates/2-col-php-header-#.php files for the most part just call the /dist-php/inc/ files as required, but I've split them up into three categories (before Metadata, in between Metadata and CSS, and after CSS). The templates give me some control to set site specific things that are common to all pages on my site and if the name of files in the /dist-php/inc/ folder change I can just make the update in my template file without having to update every single file on my site.

2-col-php-header-1.php

I look for a file of the same name as the boilerplate but in a includes directory in the same location as the boilerplate file and set $_PAGE['content'].

// use the $_PAGE['content'] variable if the content file goes by a different name 
// then the boiler plate file.
$currentFile = $_SERVER["PHP_SELF"];
$index = strrpos($currentFile, '/');
//$parts = Explode('/', $currentFile);

$_PAGE['content'] = $_SERVER['DOCUMENT_ROOT'] . substr($currentFile, 0, $index) . "/includes/" . substr($currentFile, $index+1);
2-col-php-header-3php

I include the content file previously found

<!-- Main content start -->
<?php
        include_once $_PAGE['content']; 
?>
<!-- MainContentEnd -->

from wet-boew-php.

crochefort avatar crochefort commented on July 19, 2024

I said Newsroom but it's can be for publication section or ATIP section.

ATIP need to stay on a website for 2 years. So I need a way to be able to change the title on what ever section that have an "application" on it!

I just read about global variable ... is this a good lead?

from wet-boew-php.

upsonp avatar upsonp commented on July 19, 2024

@crochefort You'd still need to set the global variables before the page is loaded. My rule of thumb is PHP is used before a page is loaded, HTML is used when the page is loaded, JavaScript is used after the page is loaded.

This might be helpful How to dynamically change a web page's title?, but I'm not sure if there's accessibility issues by changing a title after a page is loaded.

from wet-boew-php.

crochefort avatar crochefort commented on July 19, 2024

I just want to take the title that i get in php from my xml and add it in the title...

So there i'm only playing with PHP and XML .. not JS at all ...

When i comment the title in the top section and try to set it in the content section the title html tag is empty... So it's not pick-up by the php but it's still php ... so this is why I think the variable can maybe need to be global to be access anywhere in the code... (top like it's now or in the content area for application )

What do you think?

from wet-boew-php.

michael-milette avatar michael-milette commented on July 19, 2024

If you are trying to use the $PAGE['isarchived'] variable from within a function, one of the more common approaches is to re-declare it with a global scope inside your function. For example:

function MyFunction() {
global $PAGE;
// you can now use $PAGE['isarchived']
}

What this will do is make the $PAGE variable along with all of it's array contents, like $PAGE['isarchived'], available inside your function. Note that any changes you make to the variable inside your function when declared this way will affect it everywhere outside your function as well.

For more information and examples, see:
http://www.php.net/manual/en/language.variables.scope.php

Best regards,

Michael

from wet-boew-php.

upsonp avatar upsonp commented on July 19, 2024

Is there a way you can load your XML file first?

As an example using my boilerplate file from above:

<?php 

        $fileContents = //some magic to read file and create a string//;
        $xml= new SimpleXmlElement($fileContents);
    $_PAGE['title_' . $_PAGE['lang1']]  = $xml->{'xml-title'};

    $_PAGE['lang1'] = "fra";
    $_PAGE['left_menu_gauche'] = $_SERVER['DOCUMENT_ROOT']."/otoliths/includes/menus/left-menu-gauche.php";
    $_PAGE['issued'] = "2011-10-02"; 

    include_once $_SERVER['DOCUMENT_ROOT'] . "/templates/2-col-php-header-1.php";
?>

<!--custom metadata-->
<!--end of custom metadata-->

<?php include_once $_SERVER['DOCUMENT_ROOT'] . "/templates/2-col-php-header-2.php"; ?>

<!--custom css-->

<!--end of custom css-->

<?php include_once $_SERVER['DOCUMENT_ROOT'] . "/templates/2-col-php-header-3.php"; ?>

from wet-boew-php.

crochefort avatar crochefort commented on July 19, 2024

Will have to test this tomorrow @upsonp ! And @michael-milette THe Archived is after I get the title working because it's the same issue ... so all the variable that are in the first php section that Patrick show cannot be change if you put them in the content section...

from wet-boew-php.

upsonp avatar upsonp commented on July 19, 2024

@crochefort I'm glad you're not going the JavaScript route, I always save that as a last resort because you never know if some JavaScript will break in someone's browser (which Internet Explore is notorious for) or if it'll be readable by a screen reader.

I have a lot of friends who work for CNIB and it's horrifying to hear some of the stories they have for trying to do things we'd normally consider very simple.

from wet-boew-php.

crochefort avatar crochefort commented on July 19, 2024

It's now working for the mynewsroom

Snippet:
if ($_GET['id'] <> "") {
$xmlTitle = simplexml_load_file('PATH TO MY FILE');
$dynTitle = $xmlTitle->xpath('/news/item[newsId="' . $_GET['id'] . '"]');
foreach ($dynTitle as $newdynTitle)
$PAGE['title' . $_PAGE['lang1']] = $newdynTitle->newsTitleEng." | Newsroom";
}
else{
$PAGE['title' . $_PAGE['lang1']] = "Newsroom";
}

I'll will try to add the archived to later today! :)

With that I'll be able to port that over my ATIP section that is all XML... So my title will be able to change according to the month!

from wet-boew-php.

upsonp avatar upsonp commented on July 19, 2024

Good to hear,

I'll close this thread, but feel free to open it again if it needs more discussion.

from wet-boew-php.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.