Copy a Single Page Below Other Pages

Permalink
I'd like to copy a single page to 10 different other pages as a child page.

Does anyone know if this is currently possible with Concrete 5.5?

 
12345j replied on at Permalink Reply
12345j
that seems a bit counterintuitive. Maybe try using the same single page each time but passing a different parameter to it (either using GET or tasks)
rrcustom replied on at Permalink Reply
For this example, I will use a news article for multiple languages. I want to copy the page Article01.html and all of it contents for each market to translate. They will then replace the English text with the translated text for their region. Leaving any media (pictures/videos) in place as well as the general layout. As you can imagine, with hundreds of articles, doing this by hand just isn't realistic.

Here is the hierarchy:

Before:

News
-English
--Article01.html
-Spanish
-German
-Swedish
-French


After:

News
-English
--Article01.html
-Spanish
--Article01.html
-German
--Article01.html
-Swedish
--Article01.html
-French
--Article01.html
12345j replied on at Permalink Best Answer Reply
12345j
Concrete5 has a specific term that single page applies to- seehttp://www.concrete5.org/documentation/developers/pages/single-page...
so I thought you were talking about that.

To solve this problem though I'd recommend checking out events, especially the on_page_add event.http://www.concrete5.org/documentation/developers/system/events/...
something like this
public function pageAdd($page){
    $pID=$page->getCollectionParentID();
    $pp=Page::getByID($pID);
    $pName=$pp->getCollectionName();
    $langs=array('english'=>'english','spanish'=>'spanish','french'=>'french');
    unset($langs[$pName]);
    foreach($langs as $lang){
        $lp=Page::getByPath("/".$lang);
        $page->duplicate($lp);
    }
}

pretty basic example, but should get you most of the way there.
rrcustom replied on at Permalink Reply
Where exactly is this function run? Do we have to modify the core?
12345j replied on at Permalink Reply
12345j
sorry to be rude, but if you looked at the link i gave you you would know this
"Hooking into Events

Hooking into these events is pretty simple.

Add the following to your config/site.php file.

define('ENABLE_APPLICATION_EVENTS', true);
*NOTE: the above code is only need for concrete5 versions less than 5.4

Add a file named "site_events.php" to your config/ directory.

Within this file, you define events using the method

Events::extend($event, $class, $method, $filename, $params = array());
Additional Arguments

$event - event to run (e.g. "onuseradd").
$class - Class Name that contains the method you would like to run.
$method - Method you would like to run when event occurs.
$filename - File that contains the class that contains the method. Can be an absolute path or relative to the current site..
$params - any additional parameters you would like passed to your function..
Example

Let's say you would like to setup an additional row in a special database table whenever anyone adds a user. This could happen through the dashboard, or through front-end registration, and you really don't want to fork concrete5, so events are the best way to move forward with this requirement.

It's already obvious you need to hook into the "on_user_add" event. Next, choose a name for the function that will be run when doing so. How about "setupUserJoinInfo" ? Next, choose where this function will live - it has to be a class. How about just created a new class named "ApplicationUser" and a file for it in the models directory, named "models/application_user.php".

If all this is the case, this is the line you would write in your site_events.php file:

Events::extend('on_user_add', 'ApplicationUser', 'setupUserJoinInfo', 'models/application_user.php');
Then, within your ApplicationUser class, simply define

public function setupUserJoinInfo($ui) {
// $ui is the newly created user
}
Then you'd simply grab whatever information about the newly created user you needed, and place that information in the join table (likely a userID, etc...)
"
rrcustom replied on at Permalink Reply
No worries. I asked and *then* clicked. I'll go through this. Thanks for your help.
rrcustom replied on at Permalink Reply
I dug into this a bit more but it doesn't necessarily solve my problem as of right now. I have about 150 articles that I need to copy to 10+ different languages folders, so my main question still stands.

How can I copy a page to "x" amount of other pages as a sub-page, in a bulk copy? Any ideas?
12345j replied on at Permalink Reply
12345j
you could write a simple job for it, but that would probably take about as long as just doing it manually.
rrcustom replied on at Permalink Reply
are you thinking a custom script in php? or something in the database?
12345j replied on at Permalink Reply
12345j
something like this:http://www.concrete5.org/documentation/developers/system/jobs...
which is basically a wrapper for a php script, but loads the c5 environment.
12345j replied on at Permalink Reply
12345j
alternatively you could just use the internationalization addon
http://www.concrete5.org/marketplace/addons/internationalization/...
rrcustom replied on at Permalink Reply
Yes, we are aware of this addon. We will migrate to this eventually but it is not in our list yet.
brainmonger replied on at Permalink Reply
To make a copy of a page, try this:

In the sitemap section of your site, click on the page icon of the page you wish to copy, and drag it to the parent node (destination node). When the parent node is highlighted, drop.

At this point you'll be prompted to copy or move the page.